diff --git a/.gitignore b/.gitignore index 2af71adba..8cf78452c 100755 --- a/.gitignore +++ b/.gitignore @@ -19,9 +19,9 @@ local/media/documents/* local/media/images/* web/assets/* web/cache/* -web/.htaccess phpdoc*.log php-cs xhprof/ phpunit.phar -.DS_Store \ No newline at end of file +.DS_Store +phpmyadmin diff --git a/Readme.md b/Readme.md index 791b61d1e..ed4edf9ef 100755 --- a/Readme.md +++ b/Readme.md @@ -12,14 +12,33 @@ Here is the most recent developed code for the next major version (v2). You can Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet. +Requirements +------------ + +* php 5.4 +* apache 2 +* mysql 5 + +If you use Mac OSX, it still doesn't use php 5.4 as default php version... There are many solutions for you : + +* use linux (the best one) +* use last MAMP version and put the php bin directory in your path : + +```bash +export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH +``` + +* configure a complete development environment : http://php-osx.liip.ch/ +* use a virtual machine with vagrant and puppet : https://puphpet.com/ + Installation ------------ ``` bash -$ git clone --recursive https://github.com/thelia/thelia.git +$ git clone https://github.com/thelia/thelia.git $ cd thelia -$ wget http://getcomposer.org/composer.phar -$ php composer.phar install +$ curl -sS https://getcomposer.org/installer | php +$ php composer.phar install --prefer-dist --optimize-autoloader ``` Finish the installation using cli tools : diff --git a/composer.json b/composer.json index 2d315bd3a..4a3798384 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "simplepie/simplepie": "dev-master", "imagine/imagine": "dev-master", - "symfony/icu": "1.0" + "symfony/icu": "1.0", + "swiftmailer/swiftmailer": "5.0.*" }, "require-dev" : { "phpunit/phpunit": "3.7.*", @@ -53,9 +54,5 @@ "": "local/modules/", "Thelia" : "core/lib/" } - }, - "scripts" : { - "post-update-cmd": "composer dump-autoload -o", - "post-install-cmd": "composer dump-autoload -o" } } diff --git a/composer.lock b/composer.lock index 61160ea49..b0310c075 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "28dfdc7a840f9e70df422581f82a871f", + "hash": "a40be01c82e68ba0c446dc204d2667da", "packages": [ { "name": "imagine/imagine", @@ -445,6 +445,55 @@ ], "time": "2013-07-02 16:38:47" }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.0.2", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Chris Corbyn" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "mail", + "mailer" + ], + "time": "2013-08-30 12:35:21" + }, { "name": "symfony-cmf/routing", "version": "1.0.0", diff --git a/core/lib/Thelia/Action/Attribute.php b/core/lib/Thelia/Action/Attribute.php index 2877ca388..44c5968a4 100644 --- a/core/lib/Thelia/Action/Attribute.php +++ b/core/lib/Thelia/Action/Attribute.php @@ -39,6 +39,9 @@ use Thelia\Model\AttributeAvQuery; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryEvent; use Thelia\Core\Event\AttributeEvent; +use Thelia\Model\AttributeTemplate; +use Thelia\Model\AttributeTemplateQuery; +use Thelia\Model\TemplateQuery; class Attribute extends BaseAction implements EventSubscriberInterface { @@ -135,23 +138,33 @@ class Attribute extends BaseAction implements EventSubscriberInterface } } - public function addToAllTemplates(AttributeEvent $event) + protected function doAddToAllTemplates(AttributeModel $attribute) { - $templates = ProductTemplateAttributeQuery::create()->find(); + $templates = TemplateQuery::create()->find(); foreach($templates as $template) { - $pat = new ProductTemplateAttribute(); - $pat->setTemplate($template->getId()) - ->setAttributeId($event->getAttribute()->getId()) - ->save(); + $attribute_template = new AttributeTemplate(); + + if (null === AttributeTemplateQuery::create()->filterByAttribute($attribute)->filterByTemplate($template)->findOne()) { + $attribute_template + ->setAttribute($attribute) + ->setTemplate($template) + ->save() + ; + } } } + public function addToAllTemplates(AttributeEvent $event) + { + $this->doAddToAllTemplates($event->getAttribute()); + } + public function removeFromAllTemplates(AttributeEvent $event) { // Delete this attribute from all product templates - ProductTemplateAttributeQuery::create()->filterByAttributeId($event->getAttribute()->getId())->delete(); + AttributeTemplateQuery::create()->filterByAttribute($event->getAttribute())->delete(); } /** diff --git a/core/lib/Thelia/Action/BaseCachedFile.php b/core/lib/Thelia/Action/BaseCachedFile.php new file mode 100644 index 000000000..b66496e07 --- /dev/null +++ b/core/lib/Thelia/Action/BaseCachedFile.php @@ -0,0 +1,178 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Core\Event\CachedFileEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Tools\URL; + +/** + * + * Cached file management actions. This class handles file caching in the web space + * + * Basically, files are stored outside the web space (by default in local/media/), + * and cached in the web space (by default in web/local/). + * + * In the file cache directory, a subdirectory for files categories (eg. product, category, folder, etc.) is + * automatically created, and the cached file is created here. Plugin may use their own subdirectory as required. + * + * A copy (or symbolic link, by default) of the original file is created in the cache. + * + * @package Thelia\Action + * @author Franck Allimant + * + */ +abstract class BaseCachedFile extends BaseAction +{ + /** + * @return string root of the file cache directory in web space + */ + protected abstract function getCacheDirFromWebRoot(); + + /** + * Clear the file cache. Is a subdirectory is specified, only this directory is cleared. + * If no directory is specified, the whole cache is cleared. + * Only files are deleted, directories will remain. + * + * @param CachedFileEvent $event + */ + public function clearCache(CachedFileEvent $event) + { + $path = $this->getCachePath($event->getCacheSubdirectory(), false); + + $this->clearDirectory($path); + } + + /** + * Recursively clears the specified directory. + * + * @param string $path the directory path + */ + protected function clearDirectory($path) + { + $iterator = new \DirectoryIterator($path); + + foreach ($iterator as $fileinfo) { + + if ($fileinfo->isDot()) continue; + + if ($fileinfo->isFile() || $fileinfo->isLink()) { + @unlink($fileinfo->getPathname()); + } elseif ($fileinfo->isDir()) { + $this->clearDirectory($fileinfo->getPathname()); + } + } + } + + /** + * Return the absolute URL to the cached file + * + * @param string $subdir the subdirectory related to cache base + * @param string $filename the safe filename, as returned by getCacheFilePath() + * @return string the absolute URL to the cached file + */ + protected function getCacheFileURL($subdir, $safe_filename) + { + $path = $this->getCachePathFromWebRoot($subdir); + + return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE); + } + + /** + * Return the full path of the cached file + * + * @param string $subdir the subdirectory related to cache base + * @param string $filename the filename + * @param string $hashed_options a hash of transformation options, or null if no transformations have been applied + * @param boolean $forceOriginalDocument if true, the original file path in the cache dir is returned. + * @return string the cache directory path relative to Web Root + */ + protected function getCacheFilePath($subdir, $filename, $forceOriginalFile = false, $hashed_options = null) + { + $path = $this->getCachePath($subdir); + + $safe_filename = preg_replace("[^:alnum:\-\._]", "-", strtolower(basename($filename))); + + // Keep original safe name if no tranformations are applied + if ($forceOriginalFile || $hashed_options == null) + return sprintf("%s/%s", $path, $safe_filename); + else + return sprintf("%s/%s-%s", $path, $hashed_options, $safe_filename); + } + + /** + * Return the cache directory path relative to Web Root + * + * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. + * @return string the cache directory path relative to Web Root + */ + protected function getCachePathFromWebRoot($subdir = null) + { + $cache_dir_from_web_root = $this->getCacheDirFromWebRoot(); + + if ($subdir != null) { + $safe_subdir = basename($subdir); + + $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir); + } else + $path = $cache_dir_from_web_root; + + // Check if path is valid, e.g. in the cache dir + return $path; + } + + /** + * Return the absolute cache directory path + * + * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. + * @throws \RuntimeException if cache directory cannot be created + * @return string the absolute cache directory path + */ + protected function getCachePath($subdir = null, $create_if_not_exists = true) + { + $cache_base = $this->getCachePathFromWebRoot($subdir); + + $web_root = rtrim(THELIA_WEB_DIR, '/'); + + $path = sprintf("%s/%s", $web_root, $cache_base); + + // Create directory (recursively) if it does not exists. + if ($create_if_not_exists && !is_dir($path)) { + if (!@mkdir($path, 0777, true)) { + throw new \RuntimeException(sprintf("Failed to create %s/%s file in cache directory", $cache_base)); + } + } + + // Check if path is valid, e.g. in the cache dir + $cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot())); + + if (strpos(realpath($path), $cache_base) !== 0) { + throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir)); + } + + return $path; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 5549f3eb3..22760a4c7 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -65,7 +65,7 @@ class Cart extends BaseAction implements EventSubscriberInterface ->filterByProductSaleElementsId($productSaleElementsId) ->findOne(); - $this->doAddItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice); + $this->doAddItem($cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice); } if ($append && $cartItem !== null) { @@ -166,17 +166,18 @@ class Cart extends BaseAction implements EventSubscriberInterface * @param float $quantity * @param ProductPrice $productPrice */ - protected function doAddItem(\Thelia\Model\Cart $cart, $productId, $productSaleElementsId, $quantity, ProductPrice $productPrice) + protected function doAddItem(\Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice) { $cartItem = new CartItem(); $cartItem->setDisptacher($this->getDispatcher()); $cartItem ->setCart($cart) ->setProductId($productId) - ->setProductSaleElementsId($productSaleElementsId) + ->setProductSaleElementsId($productSaleElements->getId()) ->setQuantity($quantity) ->setPrice($productPrice->getPrice()) ->setPromoPrice($productPrice->getPromoPrice()) + ->setPromo($productSaleElements->getPromo()) ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)) ->save(); } diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 297cd64da..25a94711f 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -24,52 +24,92 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\Category as CategoryModel; + use Thelia\Model\CategoryQuery; +use Thelia\Model\Category as CategoryModel; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Propel; -use Thelia\Model\Map\CategoryTableMap; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryUpdateEvent; use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Core\Event\CategoryDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; -use Thelia\Core\Event\CategoryChangePositionEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery; class Category extends BaseAction implements EventSubscriberInterface { + /** + * Create a new category entry + * + * @param CategoryCreateEvent $event + */ public function create(CategoryCreateEvent $event) { $category = new CategoryModel(); $category ->setDispatcher($this->getDispatcher()) - ->create( - $event->getTitle(), - $event->getParent(), - $event->getLocale() - ); + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save() + ; $event->setCategory($category); } - public function update(CategoryChangeEvent $event) + /** + * Change a category + * + * @param CategoryUpdateEvent $event + */ + public function update(CategoryUpdateEvent $event) { + $search = CategoryQuery::create(); + + if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { + + $category + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save(); + + $event->setCategory($category); + } } /** - * Delete a category + * Delete a category entry * - * @param ActionEvent $event + * @param CategoryDeleteEvent $event */ public function delete(CategoryDeleteEvent $event) { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); + if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { - if ($category !== null) { + $category + ->setDispatcher($this->getDispatcher()) + ->delete() + ; - $category->setDispatcher($this->getDispatcher())->delete(); + $event->setCategory($category); } } @@ -80,178 +120,85 @@ class Category extends BaseAction implements EventSubscriberInterface */ public function toggleVisibility(CategoryToggleVisibilityEvent $event) { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); + $category = $event->getCategory(); - if ($category !== null) { + $category + ->setDispatcher($this->getDispatcher()) + ->setVisible($category->getVisible() ? false : true) + ->save() + ; + } - $category + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $category = CategoryQuery::create()->findPk($event->getObjectId())) { + + $category->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $category->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $category->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $category->movePositionDown(); + } + } + + public function addContent(CategoryAddContentEvent $event) { + + if (CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->count() <= 0) { + + $content = new CategoryAssociatedContent(); + + $content ->setDispatcher($this->getDispatcher()) - ->setVisible($category->getVisible() ? false : true) + ->setCategory($event->getCategory()) + ->setContentId($event->getContentId()) ->save() ; + } + } + + public function removeContent(CategoryDeleteContentEvent $event) { + + $content = CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->findOne() + ; + + if ($content !== null) { + $content + ->setDispatcher($this->getDispatcher()) + ->delete(); } } - /** - * Changes category position, selecting absolute ou relative change. - * - * @param CategoryChangePositionEvent $event - */ - public function changePosition(CategoryChangePositionEvent $event) - { - if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE) - return $this->changeAbsolutePosition($event); - else - return $this->exchangePosition($event); - } /** - * Move up or down a category - * - * @param CategoryChangePositionEvent $event - */ - protected function exchangePosition(CategoryChangePositionEvent $event) - { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); - - if ($category !== null) { - - // The current position of the category - $my_position = $category->getPosition(); - - // Find category to exchange position with - $search = CategoryQuery::create() - ->filterByParent($category->getParent()); - - // Up or down ? - if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) { - // Find the category immediately before me - $search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC); - } elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) { - // Find the category immediately after me - $search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC); - } else - - return; - - $result = $search->findOne(); - - // If we found the proper category, exchange their positions - if ($result) { - - $cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); - - $cnx->beginTransaction(); - - try { - $category - ->setDispatcher($this->getDispatcher()) - ->setPosition($result->getPosition()) - ->save() - ; - - $result->setPosition($my_position)->save(); - - $cnx->commit(); - } catch (Exception $e) { - $cnx->rollback(); - } - } - } - } - - /** - * Changes category position - * - * @param CategoryChangePositionEvent $event - */ - protected function changeAbsolutePosition(CategoryChangePositionEvent $event) - { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); - - if ($category !== null) { - - // The required position - $new_position = $event->getPosition(); - - // The current position - $current_position = $category->getPosition(); - - if ($new_position != null && $new_position > 0 && $new_position != $current_position) { - - // Find categories to offset - $search = CategoryQuery::create()->filterByParent($category->getParent()); - - if ($new_position > $current_position) { - // The new position is after the current position -> we will offset + 1 all categories located between us and the new position - $search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position)); - - $delta = -1; - } else { - // The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position - $search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1)); - - $delta = 1; - } - - $results = $search->find(); - - $cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); - - $cnx->beginTransaction(); - - try { - foreach ($results as $result) { - $result->setPosition($result->getPosition() + $delta)->save($cnx); - } - - $category - ->setDispatcher($this->getDispatcher()) - ->setPosition($new_position) - ->save($cnx) - ; - - $cnx->commit(); - } catch (Exception $e) { - $cnx->rollback(); - } - } - } - } - - /** - * Returns an array of event names this subscriber listens to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('eventName' => 'methodName') - * * array('eventName' => array('methodName', $priority)) - * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) - * - * @return array The event names to listen to - * - * @api + * {@inheritDoc} */ public static function getSubscribedEvents() { return array( - TheliaEvents::CATEGORY_CREATE => array("create", 128), - TheliaEvents::CATEGORY_UPDATE => array("update", 128), - TheliaEvents::CATEGORY_DELETE => array("delete", 128), - + TheliaEvents::CATEGORY_CREATE => array("create", 128), + TheliaEvents::CATEGORY_UPDATE => array("update", 128), + TheliaEvents::CATEGORY_DELETE => array("delete", 128), TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), - TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128), - "action.updateCategoryPositionU" => array("changePositionUp", 128), - "action.updateCategoryPositionDown" => array("changePositionDown", 128), - "action.updateCategoryPosition" => array("changePosition", 128), + TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::CATEGORY_ADD_CONTENT => array("addContent", 128), + TheliaEvents::CATEGORY_REMOVE_CONTENT => array("removeContent", 128), + ); } } diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index 83df28524..f8a7c027c 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Action; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\ConfigQuery; @@ -45,18 +44,9 @@ class Config extends BaseAction implements EventSubscriberInterface { $config = new ConfigModel(); - $config - ->setDispatcher($this->getDispatcher()) - - ->setName($event->getEventName()) - ->setValue($event->getValue()) - ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) - ->setHidden($event->getHidden()) - ->setSecured($event->getSecured()) - - ->save() - ; + $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue()) + ->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden()) + ->setSecured($event->getSecured())->save(); $event->setConfig($config); } @@ -70,18 +60,13 @@ class Config extends BaseAction implements EventSubscriberInterface { $search = ConfigQuery::create(); - if (null !== $config = $search->findOneById($event->getConfigId())) { + if (null !== $config = $search->findPk($event->getConfigId())) { if ($event->getValue() !== $config->getValue()) { - $config - ->setDispatcher($this->getDispatcher()) + $config->setDispatcher($this->getDispatcher())->setValue($event->getValue())->save(); - ->setValue($event->getValue()) - ->save() - ; - - $event->setConfig($config); + $event->setConfig($config); } } } @@ -95,23 +80,12 @@ class Config extends BaseAction implements EventSubscriberInterface { $search = ConfigQuery::create(); - if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) { + if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) { - $config - ->setDispatcher($this->getDispatcher()) - - ->setName($event->getEventName()) - ->setValue($event->getValue()) - ->setHidden($event->getHidden()) - ->setSecured($event->getSecured()) - - ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) - ->setDescription($event->getDescription()) - ->setChapo($event->getChapo()) - ->setPostscriptum($event->getPostscriptum()) - - ->save(); + $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue()) + ->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale()) + ->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum())->save(); $event->setConfig($config); } @@ -125,14 +99,11 @@ class Config extends BaseAction implements EventSubscriberInterface public function delete(ConfigDeleteEvent $event) { - if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) { + if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) { - if (! $config->getSecured()) { + if (!$config->getSecured()) { - $config - ->setDispatcher($this->getDispatcher()) - ->delete() - ; + $config->setDispatcher($this->getDispatcher())->delete(); $event->setConfig($config); } @@ -145,10 +116,15 @@ class Config extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::CONFIG_CREATE => array("create", 128), - TheliaEvents::CONFIG_SETVALUE => array("setValue", 128), - TheliaEvents::CONFIG_UPDATE => array("modify", 128), - TheliaEvents::CONFIG_DELETE => array("delete", 128), + TheliaEvents::CONFIG_CREATE => array( + "create", 128 + ), TheliaEvents::CONFIG_SETVALUE => array( + "setValue", 128 + ), TheliaEvents::CONFIG_UPDATE => array( + "modify", 128 + ), TheliaEvents::CONFIG_DELETE => array( + "delete", 128 + ), ); } } diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php new file mode 100644 index 000000000..4c8810a40 --- /dev/null +++ b/core/lib/Thelia/Action/Content.php @@ -0,0 +1,112 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Content\ContentCreateEvent; +use Thelia\Core\Event\Content\ContentUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ContentQuery; +use Thelia\Model\Content as ContentModel; +use Thelia\Model\FolderQuery; + + +/** + * Class Content + * @package Thelia\Action + * @author manuel raynaud + */ +class Content extends BaseAction implements EventSubscriberInterface +{ + + public function create(ContentCreateEvent $event) + { + $content = new ContentModel(); + + $content + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->create($event->getDefaultFolder()) + ; + + $event->setContent($content); + } + + /** + * process update content + * + * @param ContentUpdateEvent $event + */ + public function update(ContentUpdateEvent $event) + { + if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) { + $content->setDispatcher($this->getDispatcher()); + + $content + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + ->save() + ; + + $event->setContent($content); + } + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::CONTENT_CREATE => array("create", 128), + TheliaEvents::CONTENT_UPDATE => array("update", 128), + TheliaEvents::CONTENT_DELETE => array("delete", 128), + TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + + TheliaEvents::CONTENT_UPDATE_POSITION => array("updatePosition", 128), + ); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index d50f72aa8..036502c68 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -23,10 +23,16 @@ namespace Thelia\Action; +use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Constraint\ConstraintFactory; +use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Coupon\CouponFactory; +use Thelia\Coupon\CouponManager; +use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon as CouponModel; /** @@ -45,7 +51,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface /** * Occurring when a Coupon is about to be created * - * @param CouponCreateOrUpdateEvent $event Event creation or update Event + * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon */ public function create(CouponCreateOrUpdateEvent $event) { @@ -57,7 +63,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface /** * Occurring when a Coupon is about to be updated * - * @param CouponCreateOrUpdateEvent $event Event creation or update Event + * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon */ public function update(CouponCreateOrUpdateEvent $event) { @@ -69,7 +75,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface /** * Occurring when a Coupon rule is about to be updated * - * @param CouponCreateOrUpdateEvent $event Event creation or update Event + * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon Rule */ public function updateRule(CouponCreateOrUpdateEvent $event) { @@ -81,11 +87,43 @@ class Coupon extends BaseAction implements EventSubscriberInterface /** * Occurring when a Coupon rule is about to be consumed * - * @param CouponCreateOrUpdateEvent $event Event creation or update Event + * @param CouponConsumeEvent $event Event consuming Coupon */ - public function consume(CouponCreateOrUpdateEvent $event) + public function consume(CouponConsumeEvent $event) { - // @todo implements + $totalDiscount = 0; + + /** @var CouponFactory $couponFactory */ + $couponFactory = $this->container->get('thelia.coupon.factory'); + + /** @var CouponManager $couponManager */ + $couponManager = $this->container->get('thelia.coupon.manager'); + + /** @var CouponInterface $coupon */ + $coupon = $couponFactory->buildCouponFromCode($event->getCode()); + + $isValid = $coupon->isMatching(); + if ($isValid) { + /** @var Request $request */ + $request = $this->container->get('request'); + $consumedCoupons = $request->getSession()->getConsumedCoupons(); + + if (!isset($consumedCoupons) || !$consumedCoupons) { + $consumedCoupons = array(); + } + + // Prevent accumulation of the same Coupon on a Checkout + $consumedCoupons[$event->getCode()] = $event->getCode(); + + $request->getSession()->setConsumedCoupons($consumedCoupons); + + $totalDiscount = $couponManager->getDiscount(); + + // @todo modify Cart total discount + } + + $event->setIsValid($isValid); + $event->setDiscount($totalDiscount); } /** @@ -165,8 +203,6 @@ class Coupon extends BaseAction implements EventSubscriberInterface return array( TheliaEvents::COUPON_CREATE => array("create", 128), TheliaEvents::COUPON_UPDATE => array("update", 128), - TheliaEvents::COUPON_DISABLE => array("disable", 128), - TheliaEvents::COUPON_ENABLE => array("enable", 128), TheliaEvents::COUPON_CONSUME => array("consume", 128), TheliaEvents::COUPON_RULE_UPDATE => array("updateRule", 128) ); diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 7908d1f0d..946fee375 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -71,7 +71,7 @@ class Currency extends BaseAction implements EventSubscriberInterface { $search = CurrencyQuery::create(); - if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) { + if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { $currency ->setDispatcher($this->getDispatcher()) @@ -97,7 +97,7 @@ class Currency extends BaseAction implements EventSubscriberInterface { $search = CurrencyQuery::create(); - if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) { + if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { if ($currency->getByDefault() != $event->getIsDefault()) { @@ -123,7 +123,7 @@ class Currency extends BaseAction implements EventSubscriberInterface public function delete(CurrencyDeleteEvent $event) { - if (null !== ($currency = CurrencyQuery::create()->findOneById($event->getCurrencyId()))) { + if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) { $currency ->setDispatcher($this->getDispatcher()) diff --git a/core/lib/Thelia/Action/Document.php b/core/lib/Thelia/Action/Document.php new file mode 100644 index 000000000..86fc51ac5 --- /dev/null +++ b/core/lib/Thelia/Action/Document.php @@ -0,0 +1,139 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Core\Event\DocumentEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Tools\URL; + +use Imagine\Document\ImagineInterface; +use Imagine\Document\DocumentInterface; +use Imagine\Document\Box; +use Imagine\Document\Color; +use Imagine\Document\Point; +use Thelia\Exception\DocumentException; +use Thelia\Core\Event\TheliaEvents; + +/** + * + * Document management actions. This class handles document processing an caching. + * + * Basically, documents are stored outside the web space (by default in local/media/documents), + * and cached in the web space (by default in web/local/documents). + * + * In the documents caches directory, a subdirectory for documents categories (eg. product, category, folder, etc.) is + * automatically created, and the cached document is created here. Plugin may use their own subdirectory as required. + * + * The cached document name contains a hash of the processing options, and the original (normalized) name of the document. + * + * A copy (or symbolic link, by default) of the original document is always created in the cache, so that the full + * resolution document is always available. + * + * Various document processing options are available : + * + * - resizing, with border, crop, or by keeping document aspect ratio + * - rotation, in degrees, positive or negative + * - background color, applyed to empty background when creating borders or rotating + * - effects. The effects are applied in the specified order. The following effects are available: + * - gamma:value : change the document Gamma to the specified value. Example: gamma:0.7 + * - grayscale or greyscale: switch document to grayscale + * - colorize:color : apply a color mask to the document. Exemple: colorize:#ff2244 + * - negative : transform the document in its negative equivalent + * - vflip or vertical_flip : vertical flip + * - hflip or horizontal_flip : horizontal flip + * + * If a problem occurs, an DocumentException may be thrown. + * + * @package Thelia\Action + * @author Franck Allimant + * + */ +class Document extends BaseCachedFile implements EventSubscriberInterface +{ + /** + * @return string root of the document cache directory in web space + */ + protected function getCacheDirFromWebRoot() { + return ConfigQuery::read('document_cache_dir_from_web_root', 'cache'); + } + + /** + * Process document and write the result in the document cache. + * + * When the original document is required, create either a symbolic link with the + * original document in the cache dir, or copy it in the cache dir if it's not already done. + * + * This method updates the cache_file_path and file_url attributes of the event + * + * @param DocumentEvent $event + * @throws \InvalidArgumentException, DocumentException + */ + public function processDocument(DocumentEvent $event) + { + $subdir = $event->getCacheSubdirectory(); + $source_file = $event->getSourceFilepath(); + + if (null == $subdir || null == $source_file) { + throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null"); + } + + $originalDocumentPathInCache = $this->getCacheFilePath($subdir, $source_file, true); + + if (! file_exists($originalDocumentPathInCache)) { + + if (! file_exists($source_file)) { + throw new DocumentException(sprintf("Source document file %s does not exists.", $source_file)); + } + + $mode = ConfigQuery::read('original_document_delivery_mode', 'symlink'); + + if ($mode == 'symlink') { + if (false == symlink($source_file, $originalDocumentPathInCache)) { + throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($source_file), $subdir)); + } + } else {// mode = 'copy' + if (false == @copy($source_file, $originalDocumentPathInCache)) { + throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($source_file), $subdir)); + } + } + } + + // Compute the document URL + $document_url = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache)); + + // Update the event with file path and file URL + $event->setDocumentPath($originalDocumentPathInCache); + $event->setDocumentUrl(URL::getInstance()->absoluteUrl($document_url, null, URL::PATH_TO_FILE)); + } + + public static function getSubscribedEvents() + { + return array( + TheliaEvents::DOCUMENT_PROCESS => array("processDocument", 128), + TheliaEvents::DOCUMENT_CLEAR_CACHE => array("clearCache", 128), + ); + } +} diff --git a/core/lib/Thelia/Action/Feature.php b/core/lib/Thelia/Action/Feature.php new file mode 100644 index 000000000..a746ce4e2 --- /dev/null +++ b/core/lib/Thelia/Action/Feature.php @@ -0,0 +1,186 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\FeatureQuery; +use Thelia\Model\Feature as FeatureModel; + +use Thelia\Core\Event\TheliaEvents; + +use Thelia\Core\Event\FeatureUpdateEvent; +use Thelia\Core\Event\FeatureCreateEvent; +use Thelia\Core\Event\FeatureDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Model\FeatureAv; +use Thelia\Model\FeatureAvQuery; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\CategoryEvent; +use Thelia\Core\Event\FeatureEvent; +use Thelia\Model\FeatureTemplate; +use Thelia\Model\FeatureTemplateQuery; +use Thelia\Model\TemplateQuery; + +class Feature extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new feature entry + * + * @param FeatureCreateEvent $event + */ + public function create(FeatureCreateEvent $event) + { + $feature = new FeatureModel(); + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + + ->save() + ; + + $event->setFeature($feature); + + // Add atribute to all product templates if required + if ($event->getAddToAllTemplates() != 0) { + // TODO: add to all product template + } + } + + /** + * Change a product feature + * + * @param FeatureUpdateEvent $event + */ + public function update(FeatureUpdateEvent $event) + { + $search = FeatureQuery::create(); + + if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) { + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->save(); + + $event->setFeature($feature); + } + } + + /** + * Delete a product feature entry + * + * @param FeatureDeleteEvent $event + */ + public function delete(FeatureDeleteEvent $event) + { + + if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) { + + $feature + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + + $event->setFeature($feature); + } + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $feature = FeatureQuery::create()->findPk($event->getObjectId())) { + + $feature->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $feature->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $feature->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $feature->movePositionDown(); + } + } + + protected function doAddToAllTemplates(FeatureModel $feature) + { + $templates = TemplateQuery::create()->find(); + + foreach($templates as $template) { + + $feature_template = new FeatureTemplate(); + + if (null === FeatureTemplateQuery::create()->filterByFeature($feature)->filterByTemplate($template)->findOne()) { + $feature_template + ->setFeature($feature) + ->setTemplate($template) + ->save() + ; + } + } + } + + public function addToAllTemplates(FeatureEvent $event) + { + $this->doAddToAllTemplates($event->getFeature()); + } + + public function removeFromAllTemplates(FeatureEvent $event) + { + // Delete this feature from all product templates + FeatureTemplateQuery::create()->filterByFeature($event->getFeature())->delete(); + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::FEATURE_CREATE => array("create", 128), + TheliaEvents::FEATURE_UPDATE => array("update", 128), + TheliaEvents::FEATURE_DELETE => array("delete", 128), + TheliaEvents::FEATURE_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES => array("removeFromAllTemplates", 128), + TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES => array("addToAllTemplates", 128), + + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/FeatureAv.php b/core/lib/Thelia/Action/FeatureAv.php new file mode 100644 index 000000000..2bd117b4b --- /dev/null +++ b/core/lib/Thelia/Action/FeatureAv.php @@ -0,0 +1,143 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\FeatureAvQuery; +use Thelia\Model\FeatureAv as FeatureAvModel; + +use Thelia\Core\Event\TheliaEvents; + +use Thelia\Core\Event\FeatureAvUpdateEvent; +use Thelia\Core\Event\FeatureAvCreateEvent; +use Thelia\Core\Event\FeatureAvDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\UpdatePositionEvent; + +class FeatureAv extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new feature entry + * + * @param FeatureAvCreateEvent $event + */ + public function create(FeatureAvCreateEvent $event) + { + $feature = new FeatureAvModel(); + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setFeatureId($event->getFeatureId()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + + ->save() + ; + + $event->setFeatureAv($feature); + } + + /** + * Change a product feature + * + * @param FeatureAvUpdateEvent $event + */ + public function update(FeatureAvUpdateEvent $event) + { + $search = FeatureAvQuery::create(); + + if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) { + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->save(); + + $event->setFeatureAv($feature); + } + } + + /** + * Delete a product feature entry + * + * @param FeatureAvDeleteEvent $event + */ + public function delete(FeatureAvDeleteEvent $event) + { + + if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) { + + $feature + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + + $event->setFeatureAv($feature); + } + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $feature = FeatureAvQuery::create()->findPk($event->getObjectId())) { + + $feature->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $feature->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $feature->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $feature->movePositionDown(); + } + } + + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::FEATURE_AV_CREATE => array("create", 128), + TheliaEvents::FEATURE_AV_UPDATE => array("update", 128), + TheliaEvents::FEATURE_AV_DELETE => array("delete", 128), + TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128), + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php new file mode 100644 index 000000000..b830947cc --- /dev/null +++ b/core/lib/Thelia/Action/Folder.php @@ -0,0 +1,155 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\FolderCreateEvent; +use Thelia\Core\Event\FolderDeleteEvent; +use Thelia\Core\Event\FolderToggleVisibilityEvent; +use Thelia\Core\Event\FolderUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\FolderQuery; +use Thelia\Model\Folder as FolderModel; + + +/** + * Class Folder + * @package Thelia\Action + * @author Manuel Raynaud + */ +class Folder extends BaseAction implements EventSubscriberInterface { + + + public function update(FolderUpdateEvent $event) + { + + if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { + $folder->setDispatcher($this->getDispatcher()); + + $folder + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + ->save(); + ; + + $event->setFolder($folder); + } + } + + public function delete(FolderDeleteEvent $event) + { + if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { + $folder->setDispatcher($this->getDispatcher()) + ->delete(); + + $event->setFolder($folder); + } + } + + /** + * @param FolderCreateEvent $event + */ + public function create(FolderCreateEvent $event) + { + $folder = new FolderModel(); + $folder->setDispatcher($this->getDispatcher()); + + $folder + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->save(); + + $event->setFolder($folder); + } + + public function toggleVisibility(FolderToggleVisibilityEvent $event) + { + $folder = $event->getFolder(); + + $folder + ->setDispatcher($this->getDispatcher()) + ->setVisible(!$folder->getVisible()) + ->save(); + + } + + public function updatePosition(UpdatePositionEvent $event) + { + if(null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) { + $folder->setDispatcher($this->getDispatcher()); + + switch($event->getMode()) + { + case UpdatePositionEvent::POSITION_ABSOLUTE: + $folder->changeAbsolutePosition($event->getPosition()); + break; + case UpdatePositionEvent::POSITION_DOWN: + $folder->movePositionDown(); + break; + case UpdatePositionEvent::POSITION_UP: + $folder->movePositionUp(); + break; + } + } + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::FOLDER_CREATE => array("create", 128), + TheliaEvents::FOLDER_UPDATE => array("update", 128), + TheliaEvents::FOLDER_DELETE => array("delete", 128), + TheliaEvents::FOLDER_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + + TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128), + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/HttpException.php b/core/lib/Thelia/Action/HttpException.php index 9cb9fab13..9beadeb7b 100755 --- a/core/lib/Thelia/Action/HttpException.php +++ b/core/lib/Thelia/Action/HttpException.php @@ -26,6 +26,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\KernelEvents; use Thelia\Model\ConfigQuery; @@ -43,6 +44,10 @@ class HttpException extends BaseAction implements EventSubscriberInterface if ($event->getException() instanceof NotFoundHttpException) { $this->display404($event); } + + if($event->getException() instanceof AccessDeniedHttpException) { + $this->display403($event); + } } protected function display404(GetResponseForExceptionEvent $event) diff --git a/core/lib/Thelia/Action/Image.php b/core/lib/Thelia/Action/Image.php index 66baffdbb..4660f93b8 100755 --- a/core/lib/Thelia/Action/Image.php +++ b/core/lib/Thelia/Action/Image.php @@ -71,7 +71,7 @@ use Thelia\Core\Event\TheliaEvents; * @author Franck Allimant * */ -class Image extends BaseAction implements EventSubscriberInterface +class Image extends BaseCachedFile implements EventSubscriberInterface { // Resize mode constants const EXACT_RATIO_WITH_BORDERS = 1; @@ -79,38 +79,10 @@ class Image extends BaseAction implements EventSubscriberInterface const KEEP_IMAGE_RATIO = 3; /** - * Clear the image cache. Is a subdirectory is specified, only this directory is cleared. - * If no directory is specified, the whole cache is cleared. - * Only files are deleted, directories will remain. - * - * @param ImageEvent $event + * @return string root of the image cache directory in web space */ - public function clearCache(ImageEvent $event) - { - $path = $this->getCachePath($event->getCacheSubdirectory(), false); - - $this->clearDirectory($path); - } - - /** - * Recursively clears the specified directory. - * - * @param string $path the directory path - */ - protected function clearDirectory($path) - { - $iterator = new \DirectoryIterator($path); - - foreach ($iterator as $fileinfo) { - - if ($fileinfo->isDot()) continue; - - if ($fileinfo->isFile() || $fileinfo->isLink()) { - @unlink($fileinfo->getPathname()); - } elseif ($fileinfo->isDir()) { - $this->clearDirectory($fileinfo->getPathname()); - } - } + protected function getCacheDirFromWebRoot() { + return ConfigQuery::read('image_cache_dir_from_web_root', 'cache'); } /** @@ -138,9 +110,9 @@ class Image extends BaseAction implements EventSubscriberInterface // echo basename($source_file).": "; // Find cached file path - $cacheFilePath = $this->getCacheFilePath($subdir, $source_file, $event); + $cacheFilePath = $this->getCacheFilePath($subdir, $source_file, $event->isOriginalImage(), $event->getOptionsHash()); - $originalImagePathInCache = $this->getCacheFilePath($subdir, $source_file, $event, true); + $originalImagePathInCache = $this->getCacheFilePath($subdir, $source_file, true); if (! file_exists($cacheFilePath)) { @@ -359,94 +331,6 @@ class Image extends BaseAction implements EventSubscriberInterface return $image; } - /** - * Return the absolute URL to the cached image - * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the safe filename, as returned by getCacheFilePath() - * @return string the absolute URL to the cached image - */ - protected function getCacheFileURL($subdir, $safe_filename) - { - $path = $this->getCachePathFromWebRoot($subdir); - - return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE); - } - - /** - * Return the full path of the cached file - * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the filename - * @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned. - * @return string the cache directory path relative to Web Root - */ - protected function getCacheFilePath($subdir, $filename, ImageEvent $event, $forceOriginalImage = false) - { - $path = $this->getCachePath($subdir); - - $safe_filename = preg_replace("[^:alnum:\-\._]", "-", strtolower(basename($filename))); - - // Keep original safe name if no tranformations are applied - if ($forceOriginalImage || $event->isOriginalImage()) - return sprintf("%s/%s", $path, $safe_filename); - else - return sprintf("%s/%s-%s", $path, $event->getOptionsHash(), $safe_filename); - } - - /** - * Return the cache directory path relative to Web Root - * - * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. - * @return string the cache directory path relative to Web Root - */ - protected function getCachePathFromWebRoot($subdir = null) - { - $cache_dir_from_web_root = ConfigQuery::read('image_cache_dir_from_web_root', 'cache'); - - if ($subdir != null) { - $safe_subdir = basename($subdir); - - $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir); - } else - $path = $cache_dir_from_web_root; - - // Check if path is valid, e.g. in the cache dir - return $path; - } - - /** - * Return the absolute cache directory path - * - * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. - * @throws \RuntimeException if cache directory cannot be created - * @return string the absolute cache directory path - */ - protected function getCachePath($subdir = null, $create_if_not_exists = true) - { - $cache_base = $this->getCachePathFromWebRoot($subdir); - - $web_root = rtrim(THELIA_WEB_DIR, '/'); - - $path = sprintf("%s/%s", $web_root, $cache_base); - - // Create directory (recursively) if it does not exists. - if ($create_if_not_exists && !is_dir($path)) { - if (!@mkdir($path, 0777, true)) { - throw new ImageException(sprintf("Failed to create %s/%s image cache directory", $cache_base)); - } - } - - // Check if path is valid, e.g. in the cache dir - $cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot())); - - if (strpos(realpath($path), $cache_base) !== 0) { - throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir)); - } - - return $path; - } - /** * Create a new Imagine object using current driver configuration * diff --git a/core/lib/Thelia/Action/Message.php b/core/lib/Thelia/Action/Message.php index faac35bf2..8918913fe 100644 --- a/core/lib/Thelia/Action/Message.php +++ b/core/lib/Thelia/Action/Message.php @@ -70,7 +70,7 @@ class Message extends BaseAction implements EventSubscriberInterface { $search = MessageQuery::create(); - if (null !== $message = MessageQuery::create()->findOneById($event->getMessageId())) { + if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) { $message ->setDispatcher($this->getDispatcher()) @@ -99,7 +99,7 @@ class Message extends BaseAction implements EventSubscriberInterface public function delete(MessageDeleteEvent $event) { - if (null !== ($message = MessageQuery::create()->findOneById($event->getMessageId()))) { + if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) { $message ->setDispatcher($this->getDispatcher()) diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php new file mode 100755 index 000000000..f93733da3 --- /dev/null +++ b/core/lib/Thelia/Action/Order.php @@ -0,0 +1,350 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Exception\OrderException; +use Thelia\Exception\TheliaProcessException; +use Thelia\Model\AddressQuery; +use Thelia\Model\OrderProductAttributeCombination; +use Thelia\Model\ModuleQuery; +use Thelia\Model\OrderProduct; +use Thelia\Model\OrderStatus; +use Thelia\Model\Map\OrderTableMap; +use Thelia\Model\OrderAddress; +use Thelia\Model\OrderStatusQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Tools\I18n; + +/** + * + * Class Order + * @package Thelia\Action + * @author Etienne Roudeix + */ +class Order extends BaseAction implements EventSubscriberInterface +{ + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setDeliveryAddress(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->chosenDeliveryAddress = $event->getDeliveryAddress(); + + $event->setOrder($order); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setDeliveryModule(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->setDeliveryModuleId($event->getDeliveryModule()); + $order->setPostage($event->getPostage()); + + $event->setOrder($order); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setInvoiceAddress(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->chosenInvoiceAddress = $event->getInvoiceAddress(); + + $event->setOrder($order); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setPaymentModule(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->setPaymentModuleId($event->getPaymentModule()); + + $event->setOrder($order); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function create(OrderEvent $event) + { + $con = \Propel\Runtime\Propel::getConnection( + OrderTableMap::DATABASE_NAME + ); + + $con->beginTransaction(); + + $sessionOrder = $event->getOrder(); + + /* use a copy to avoid errored reccord in session */ + $placedOrder = $sessionOrder->copy(); + $placedOrder->setDispatcher($this->getDispatcher()); + + $customer = $this->getSecurityContext()->getCustomerUser(); + $currency = $this->getSession()->getCurrency(); + $lang = $this->getSession()->getLang(); + $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); + $taxCountry = $deliveryAddress->getCountry(); + $invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress); + $cart = $this->getSession()->getCart(); + $cartItems = $cart->getCartItems(); + + $paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId()); + + /* fulfill order */ + $placedOrder->setCustomerId($customer->getId()); + $placedOrder->setCurrencyId($currency->getId()); + $placedOrder->setCurrencyRate($currency->getRate()); + $placedOrder->setLangId($lang->getId()); + + /* hard save the delivery and invoice addresses */ + $deliveryOrderAddress = new OrderAddress(); + $deliveryOrderAddress + ->setCustomerTitleId($deliveryAddress->getTitleId()) + ->setCompany($deliveryAddress->getCompany()) + ->setFirstname($deliveryAddress->getFirstname()) + ->setLastname($deliveryAddress->getLastname()) + ->setAddress1($deliveryAddress->getAddress1()) + ->setAddress2($deliveryAddress->getAddress2()) + ->setAddress3($deliveryAddress->getAddress3()) + ->setZipcode($deliveryAddress->getZipcode()) + ->setCity($deliveryAddress->getCity()) + ->setPhone($deliveryAddress->getPhone()) + ->setCountryId($deliveryAddress->getCountryId()) + ->save($con) + ; + + $invoiceOrderAddress = new OrderAddress(); + $invoiceOrderAddress + ->setCustomerTitleId($invoiceAddress->getTitleId()) + ->setCompany($invoiceAddress->getCompany()) + ->setFirstname($invoiceAddress->getFirstname()) + ->setLastname($invoiceAddress->getLastname()) + ->setAddress1($invoiceAddress->getAddress1()) + ->setAddress2($invoiceAddress->getAddress2()) + ->setAddress3($invoiceAddress->getAddress3()) + ->setZipcode($invoiceAddress->getZipcode()) + ->setCity($invoiceAddress->getCity()) + ->setPhone($invoiceAddress->getPhone()) + ->setCountryId($invoiceAddress->getCountryId()) + ->save($con) + ; + + $placedOrder->setDeliveryOrderAddressId($deliveryOrderAddress->getId()); + $placedOrder->setInvoiceOrderAddressId($invoiceOrderAddress->getId()); + + $placedOrder->setStatusId( + OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID)->getId() + ); + + $placedOrder->save($con); + + /* fulfill order_products and decrease stock */ + + foreach($cartItems as $cartItem) { + $product = $cartItem->getProduct(); + + /* get translation */ + $productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId()); + + $pse = $cartItem->getProductSaleElements(); + + /* check still in stock */ + if($cartItem->getQuantity() > $pse->getQuantity()) { + throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem); + } + + /* decrease stock */ + $pse->setQuantity( + $pse->getQuantity() - $cartItem->getQuantity() + ); + $pse->save($con); + + /* get tax */ + $taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId()); + + $taxDetail = $product->getTaxRule()->getTaxDetail( + $taxCountry, + $cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(), + $this->getSession()->getLang()->getLocale() + ); + + $orderProduct = new OrderProduct(); + $orderProduct + ->setOrderId($placedOrder->getId()) + ->setProductRef($product->getRef()) + ->setProductSaleElementsRef($pse->getRef()) + ->setTitle($productI18n->getTitle()) + ->setChapo($productI18n->getChapo()) + ->setDescription($productI18n->getDescription()) + ->setPostscriptum($productI18n->getPostscriptum()) + ->setQuantity($cartItem->getQuantity()) + ->setPrice($cartItem->getPrice()) + ->setPromoPrice($cartItem->getPromoPrice()) + ->setWasNew($pse->getNewness()) + ->setWasInPromo($cartItem->getPromo()) + ->setWeight($pse->getWeight()) + ->setTaxRuleTitle($taxRuleI18n->getTitle()) + ->setTaxRuleDescription($taxRuleI18n->getDescription()) + ; + $orderProduct->setDispatcher($this->getDispatcher()); + $orderProduct->save($con); + + /* fulfill order_product_tax */ + foreach($taxDetail as $tax) { + $tax->setOrderProductId($orderProduct->getId()); + $tax->save($con); + } + + /* fulfill order_attribute_combination and decrease stock */ + foreach($pse->getAttributeCombinations() as $attributeCombination) { + $attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId()); + $attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId()); + + $orderAttributeCombination = new OrderProductAttributeCombination(); + $orderAttributeCombination + ->setOrderProductId($orderProduct->getId()) + ->setAttributeTitle($attribute->getTitle()) + ->setAttributeChapo($attribute->getChapo()) + ->setAttributeDescription($attribute->getDescription()) + ->setAttributePostscriptumn($attribute->getPostscriptum()) + ->setAttributeAvTitle($attributeAv->getTitle()) + ->setAttributeAvChapo($attributeAv->getChapo()) + ->setAttributeAvDescription($attributeAv->getDescription()) + ->setAttributeAvPostscriptum($attributeAv->getPostscriptum()) + ; + + $orderAttributeCombination->save($con); + } + } + + /* discount @todo */ + + $con->commit(); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); + + /* clear session */ + /* but memorize placed order */ + $sessionOrder = new \Thelia\Model\Order(); + $event->setOrder($sessionOrder); + $event->setPlacedOrder($placedOrder); + $this->getSession()->setOrder($sessionOrder); + + /* empty cart @todo */ + + /* call pay method */ + $paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); + $paymentModuleInstance = $paymentModuleReflection->newInstance(); + + $paymentModuleInstance->setRequest($this->getRequest()); + $paymentModuleInstance->setDispatcher($this->getDispatcher()); + + $paymentModuleInstance->pay($placedOrder); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function sendOrderEmail(OrderEvent $event) + { + /* @todo */ + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::ORDER_SET_DELIVERY_ADDRESS => array("setDeliveryAddress", 128), + TheliaEvents::ORDER_SET_DELIVERY_MODULE => array("setDeliveryModule", 128), + TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128), + TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128), + TheliaEvents::ORDER_PAY => array("create", 128), + TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128), + ); + } + + /** + * Return the security context + * + * @return SecurityContext + */ + protected function getSecurityContext() + { + return $this->container->get('thelia.securityContext'); + } + + /** + * @return \Symfony\Component\HttpFoundation\Request + */ + protected function getRequest() + { + return $this->container->get('request'); + } + + /** + * Returns the session from the current request + * + * @return \Thelia\Core\HttpFoundation\Session\Session + */ + protected function getSession() + { + $request = $this->getRequest(); + + return $request->getSession(); + } +} diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php new file mode 100644 index 000000000..69a07c157 --- /dev/null +++ b/core/lib/Thelia/Action/Product.php @@ -0,0 +1,271 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\ProductQuery; +use Thelia\Model\Product as ProductModel; + +use Thelia\Core\Event\TheliaEvents; + +use Thelia\Core\Event\ProductUpdateEvent; +use Thelia\Core\Event\ProductCreateEvent; +use Thelia\Core\Event\ProductDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\ProductToggleVisibilityEvent; +use Thelia\Core\Event\ProductAddContentEvent; +use Thelia\Core\Event\ProductDeleteContentEvent; +use Thelia\Model\ProductAssociatedContent; +use Thelia\Model\ProductAssociatedContentQuery; +use Thelia\Model\ProductCategory; +use Thelia\Model\TaxRule; +use Thelia\Model\TaxRuleQuery; +use Thelia\Model\TaxQuery; +use Thelia\Model\AccessoryQuery; +use Thelia\Model\Accessory; +use Thelia\Core\Event\ProductAddAccessoryEvent; +use Thelia\Core\Event\ProductDeleteAccessoryEvent; + +class Product extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new product entry + * + * @param ProductCreateEvent $event + */ + public function create(ProductCreateEvent $event) + { + $product = new ProductModel(); + + $product + ->setDispatcher($this->getDispatcher()) + + ->setRef($event->getRef()) + ->setTitle($event->getTitle()) + ->setLocale($event->getLocale()) + ->setVisible($event->getVisible()) + + // Set the default tax rule to this product + ->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true)) + + ->create($event->getDefaultCategory()) + ; + + $event->setProduct($product); + } + + /** + * Change a product + * + * @param ProductUpdateEvent $event + */ + public function update(ProductUpdateEvent $event) + { + $search = ProductQuery::create(); + + if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { + + $product + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save(); + + $event->setProduct($product); + } + } + + /** + * Delete a product entry + * + * @param ProductDeleteEvent $event + */ + public function delete(ProductDeleteEvent $event) + { + if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { + + $product + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + + $event->setProduct($product); + } + } + + /** + * Toggle product visibility. No form used here + * + * @param ActionEvent $event + */ + public function toggleVisibility(ProductToggleVisibilityEvent $event) + { + $product = $event->getProduct(); + + $product + ->setDispatcher($this->getDispatcher()) + ->setVisible($product->getVisible() ? false : true) + ->save() + ; + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param ProductChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $product = ProductQuery::create()->findPk($event->getObjectId())) { + + $product->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $product->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $product->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $product->movePositionDown(); + } + } + + public function addContent(ProductAddContentEvent $event) { + + if (ProductAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByProduct($event->getProduct())->count() <= 0) { + + $content = new ProductAssociatedContent(); + + $content + ->setDispatcher($this->getDispatcher()) + ->setProduct($event->getProduct()) + ->setContentId($event->getContentId()) + ->save() + ; + } + } + + public function removeContent(ProductDeleteContentEvent $event) { + + $content = ProductAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByProduct($event->getProduct())->findOne() + ; + + if ($content !== null) + $content + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + } + + public function addAccessory(ProductAddAccessoryEvent $event) { + + if (AccessoryQuery::create() + ->filterByAccessory($event->getAccessoryId()) + ->filterByProductId($event->getProduct()->getId())->count() <= 0) { + + $accessory = new Accessory(); + + $accessory + ->setDispatcher($this->getDispatcher()) + ->setProductId($event->getProduct()->getId()) + ->setAccessory($event->getAccessoryId()) + ->save() + ; + } + } + + public function removeAccessory(ProductDeleteAccessoryEvent $event) { + + $accessory = AccessoryQuery::create() + ->filterByAccessory($event->getAccessoryId()) + ->filterByProductId($event->getProduct()->getId())->findOne() + ; + + if ($accessory !== null) + $accessory + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + } + + + /** + * Changes position, selecting absolute ou relative change. + * + * @param ProductChangePositionEvent $event + */ + public function updateAccessoryPosition(UpdatePositionEvent $event) + { + if (null !== $accessory = AccessoryQuery::create()->findPk($event->getObjectId())) { + + $accessory->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $accessory->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $accessory->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $accessory->movePositionDown(); + } + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::PRODUCT_CREATE => array("create", 128), + TheliaEvents::PRODUCT_UPDATE => array("update", 128), + TheliaEvents::PRODUCT_DELETE => array("delete", 128), + TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + + TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128), + TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128), + TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128), + + TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128), + TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128), + ); + } +} diff --git a/core/lib/Thelia/Action/Template.php b/core/lib/Thelia/Action/Template.php new file mode 100644 index 000000000..18174dd26 --- /dev/null +++ b/core/lib/Thelia/Action/Template.php @@ -0,0 +1,190 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\TemplateQuery; +use Thelia\Model\Template as TemplateModel; + +use Thelia\Core\Event\TheliaEvents; + +use Thelia\Core\Event\TemplateUpdateEvent; +use Thelia\Core\Event\TemplateCreateEvent; +use Thelia\Core\Event\TemplateDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Model\TemplateAv; +use Thelia\Model\TemplateAvQuery; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\CategoryEvent; +use Thelia\Core\Event\TemplateEvent; +use Thelia\Model\TemplateTemplate; +use Thelia\Model\TemplateTemplateQuery; +use Thelia\Model\ProductQuery; +use Thelia\Core\Event\TemplateAddAttributeEvent; +use Thelia\Core\Event\TemplateDeleteAttributeEvent; +use Thelia\Model\AttributeTemplateQuery; +use Thelia\Model\AttributeTemplate; +use Thelia\Core\Event\TemplateDeleteFeatureEvent; +use Thelia\Core\Event\TemplateAddFeatureEvent; +use Thelia\Model\FeatureTemplateQuery; +use Thelia\Model\FeatureTemplate; + +class Template extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new template entry + * + * @param TemplateCreateEvent $event + */ + public function create(TemplateCreateEvent $event) + { + $template = new TemplateModel(); + + $template + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setName($event->getTemplateName()) + + ->save() + ; + + $event->setTemplate($template); + } + + /** + * Change a product template + * + * @param TemplateUpdateEvent $event + */ + public function update(TemplateUpdateEvent $event) + { + $search = TemplateQuery::create(); + + if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) { + + $template + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setName($event->getTemplateName()) + ->save(); + + $event->setTemplate($template); + } + } + + /** + * Delete a product template entry + * + * @param TemplateDeleteEvent $event + */ + public function delete(TemplateDeleteEvent $event) + { + if (null !== ($template = TemplateQuery::create()->findPk($event->getTemplateId()))) { + + // Check if template is used by a product + $product_count = ProductQuery::create()->findByTemplateId($template->getId())->count(); + + if ($product_count <= 0) { + $template + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + } + + $event->setTemplate($template); + + $event->setProductCount($product_count); + } + } + + public function addAttribute(TemplateAddAttributeEvent $event) { + + if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) { + + $attribute_template = new AttributeTemplate(); + + $attribute_template + ->setAttributeId($event->getAttributeId()) + ->setTemplate($event->getTemplate()) + ->save() + ; + } + } + + public function deleteAttribute(TemplateDeleteAttributeEvent $event) { + + $attribute_template = AttributeTemplateQuery::create() + ->filterByAttributeId($event->getAttributeId()) + ->filterByTemplate($event->getTemplate())->findOne() + ; + + if ($attribute_template !== null) $attribute_template->delete(); + } + + public function addFeature(TemplateAddFeatureEvent $event) { + + if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) { + + $feature_template = new FeatureTemplate(); + + $feature_template + ->setFeatureId($event->getFeatureId()) + ->setTemplate($event->getTemplate()) + ->save() + ; + } + } + + public function deleteFeature(TemplateDeleteFeatureEvent $event) { + + $feature_template = FeatureTemplateQuery::create() + ->filterByFeatureId($event->getFeatureId()) + ->filterByTemplate($event->getTemplate())->findOne() + ; + + if ($feature_template !== null) $feature_template->delete(); + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::TEMPLATE_CREATE => array("create", 128), + TheliaEvents::TEMPLATE_UPDATE => array("update", 128), + TheliaEvents::TEMPLATE_DELETE => array("delete", 128), + + TheliaEvents::TEMPLATE_ADD_ATTRIBUTE => array("addAttribute", 128), + TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE => array("deleteAttribute", 128), + + TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128), + TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128), + + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index 8589f25b5..8ced1b6c1 100755 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -139,4 +139,6 @@ trait CartTrait return $id; } + + abstract public function getDispatcher(); } diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index 72b7571d2..1126f99a6 100755 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -62,26 +62,34 @@ class CacheClear extends ContainerAwareCommand $this->clearCache($cacheDir, $output); if (!$input->getOption("without-assets")) { - $this->clearCache(THELIA_WEB_DIR . "/assets", $output); + $this->clearCache(THELIA_WEB_DIR . "assets", $output); } } protected function clearCache($dir, OutputInterface $output) { - if (!is_writable($dir)) { - throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $dir)); - } - $output->writeln(sprintf("Clearing cache in %s directory", $dir)); + try { + $directoryBrowser = new \DirectoryIterator($dir); + } catch(\UnexpectedValueException $e) { + // throws same exception code for does not exist and permission denied ... + if(!file_exists($dir)) { + $output->writeln(sprintf("%s cache dir already clear", $dir)); + return; + } + + throw $e; + } + $fs = new Filesystem(); try { $fs->remove($dir); $output->writeln(sprintf("%s cache dir cleared successfully", $dir)); } catch (IOException $e) { - $output->writeln(sprintf("error during clearing cache : %s", $e->getMessage())); + $output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage())); } } } diff --git a/core/lib/Thelia/Command/ModuleActivateCommand.php b/core/lib/Thelia/Command/ModuleActivateCommand.php new file mode 100755 index 000000000..cddfd5290 --- /dev/null +++ b/core/lib/Thelia/Command/ModuleActivateCommand.php @@ -0,0 +1,90 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Exception\IOException; + +use Thelia\Command\ContainerAwareCommand; +use Thelia\Model\ModuleQuery; + +/** + * activates a module + * + * Class ModuleActivateCommand + * @package Thelia\Command + * @author Etienne Roudeix + * + */ +class ModuleActivateCommand extends BaseModuleGenerate +{ + protected function configure() + { + $this + ->setName("module:activate") + ->setDescription("Activates a module") + ->addArgument( + "module" , + InputArgument::REQUIRED, + "module to activate" + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $moduleCode = $this->formatModuleName($input->getArgument("module")); + + $module = ModuleQuery::create()->findOneByCode($moduleCode); + + if(null === $module) { + throw new \RuntimeException(sprintf("module %s not found", $moduleCode)); + } + + try { + new \TheliaDebugBar\TheliaDebugBar(); + + $moduleReflection = new \ReflectionClass($module->getFullNamespace()); + + $moduleInstance = $moduleReflection->newInstance(); + + $moduleInstance->activate(); + } catch(\Exception $e) { + throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage())); + } + + //impossible to change output class in CommandTester... + if (method_exists($output, "renderBlock")) { + $output->renderBlock(array( + '', + sprintf("Activation succeed for module %s", $moduleCode), + '' + ), "bg=green;fg=black"); + } + } +} diff --git a/core/lib/Thelia/Command/ReloadDatabaseCommand.php b/core/lib/Thelia/Command/ReloadDatabaseCommand.php index 70fab56d9..311b20552 100644 --- a/core/lib/Thelia/Command/ReloadDatabaseCommand.php +++ b/core/lib/Thelia/Command/ReloadDatabaseCommand.php @@ -54,6 +54,13 @@ class ReloadDatabaseCommand extends BaseModuleGenerate $connection = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $connection = $connection->getWrappedConnection(); + $tables = $connection->query("SHOW TABLES"); + $connection->query("SET FOREIGN_KEY_CHECKS = 0"); + foreach($tables as $table) { + $connection->query(sprintf("DROP TABLE `%s`", $table[0])); + } + $connection->query("SET FOREIGN_KEY_CHECKS = 1"); + $database = new Database($connection); $output->writeln(array( '', diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 2b86ed33e..15839df95 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -17,6 +17,11 @@ + + + + + @@ -37,6 +42,11 @@ + + + + + @@ -57,21 +67,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index ddb32cf65..809c62a33 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -18,27 +18,34 @@ - + + + + + + +
+ @@ -50,13 +57,25 @@ - + + + + + + + + + + + + + @@ -71,7 +90,21 @@ + + + + + + + + + + + + + + @@ -82,6 +115,7 @@ + @@ -188,6 +222,7 @@ + @@ -196,6 +231,7 @@ + @@ -230,6 +266,8 @@ + + @@ -252,6 +290,10 @@ + + + + diff --git a/core/lib/Thelia/Config/Resources/routing.xml b/core/lib/Thelia/Config/Resources/routing.xml index a8ad18abf..efeea61e8 100755 --- a/core/lib/Thelia/Config/Resources/routing.xml +++ b/core/lib/Thelia/Config/Resources/routing.xml @@ -56,17 +56,6 @@ - - - install.xml - - %kernel.cache_dir% - %kernel.debug% - - - - - front.xml diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index c16ee05bd..838bd6da8 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -24,6 +24,12 @@ Thelia\Controller\Admin\SessionController::checkLoginAction + + + Thelia\Controller\Admin\AdminController::updateAction + + + @@ -85,7 +91,7 @@ - Thelia\Controller\Admin\CategoryController::toggleOnlineAction + Thelia\Controller\Admin\CategoryController::setToggleVisibilityAction @@ -95,33 +101,164 @@ Thelia\Controller\Admin\CategoryController::updatePositionAction + + + Thelia\Controller\Admin\CategoryController::addRelatedContentAction + + + + Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction + + + + Thelia\Controller\Admin\CategoryController::getAvailableRelatedContentAction + xml|json + + Thelia\Controller\Admin\CategoryController::getByParentIdAction xml|json + + + + Thelia\Controller\Admin\ProductController::defaultAction + + + + Thelia\Controller\Admin\ProductController::createAction + + + + Thelia\Controller\Admin\ProductController::updateAction + + + + Thelia\Controller\Admin\ProductController::processUpdateAction + + + + Thelia\Controller\Admin\ProductController::setToggleVisibilityAction + + + + Thelia\Controller\Admin\ProductController::deleteAction + + + + Thelia\Controller\Admin\ProductController::updatePositionAction + + + + + + Thelia\Controller\Admin\ProductController::addRelatedContentAction + + + + Thelia\Controller\Admin\ProductController::deleteRelatedContentAction + + + + Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction + xml|json + + + + + + Thelia\Controller\Admin\ProductController::addAccessoryAction + + + + Thelia\Controller\Admin\ProductController::deleteAccessoryAction + + + + Thelia\Controller\Admin\ProductController::getAvailableAccessoriesAction + xml|json + + + + Thelia\Controller\Admin\ProductController::updateAccessoryPositionAction + + + + + + Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction + + + + + + Thelia\Controller\Admin\FolderController::defaultAction + + + + Thelia\Controller\Admin\FolderController::createAction + + + + Thelia\Controller\Admin\FolderController::updateAction + \d+ + + + + Thelia\Controller\Admin\FolderController::setToggleVisibilityAction + + + + Thelia\Controller\Admin\FolderController::processUpdateAction + + + + Thelia\Controller\Admin\FolderController::deleteAction + + + + Thelia\Controller\Admin\FolderController::updatePositionAction + + + + + Thelia\Controller\Admin\ContentController::createAction + + + + Thelia\Controller\Admin\ContentController::updateAction + \d+ + + + + Thelia\Controller\Admin\ContentController::processUpdateAction + + - + Thelia\Controller\Admin\CouponController::browseAction - + Thelia\Controller\Admin\CouponController::createAction - + Thelia\Controller\Admin\CouponController::updateAction - + Thelia\Controller\Admin\CouponController::readAction - + Thelia\Controller\Admin\CouponController::getRuleInputAction Thelia\Controller\Admin\CouponController::updateRulesAction - + + Thelia\Controller\Admin\CouponController::consumeAction + @@ -210,6 +347,53 @@ + + + + Thelia\Controller\Admin\TemplateController::defaultAction + + + + Thelia\Controller\Admin\TemplateController::createAction + + + + Thelia\Controller\Admin\TemplateController::updateAction + + + + Thelia\Controller\Admin\TemplateController::processUpdateAction + + + + Thelia\Controller\Admin\TemplateController::deleteAction + + + + Thelia\Controller\Admin\TemplateController::getAjaxFeaturesAction + + + + Thelia\Controller\Admin\TemplateController::addFeatureAction + + + + Thelia\Controller\Admin\TemplateController::deleteFeatureAction + + + + Thelia\Controller\Admin\TemplateController::getAjaxAttributesAction + + + + Thelia\Controller\Admin\TemplateController::addAttributeAction + + + + Thelia\Controller\Admin\TemplateController::deleteAttributeAction + + + @@ -267,6 +451,116 @@ + + + + Thelia\Controller\Admin\CountryController::indexAction + + + + Thelia\Controller\Admin\CountryController::createAction + + + + Thelia\Controller\Admin\CountryController::updateAction + \d+ + + + + + + + + Thelia\Controller\Admin\ShippingZoneController::indexAction + + + + Thelia\Controller\Admin\ShippingZoneController::updateAction + \d+ + + + + + + + + Thelia\Controller\Admin\ShippingConfigurationController::indexAction + + + + Thelia\Controller\Admin\ShippingConfigurationController::updateAction + \d+ + + + + + + + + + Thelia\Controller\Admin\FeatureController::defaultAction + + + + Thelia\Controller\Admin\FeatureController::createAction + + + + Thelia\Controller\Admin\FeatureController::updateAction + + + + Thelia\Controller\Admin\FeatureController::processUpdateAction + + + + Thelia\Controller\Admin\FeatureController::deleteAction + + + + Thelia\Controller\Admin\FeatureController::updatePositionAction + + + + Thelia\Controller\Admin\FeatureController::removeFromAllTemplates + + + + Thelia\Controller\Admin\FeatureController::addToAllTemplates + + + + + Thelia\Controller\Admin\FeatureAvController::createAction + + + + Thelia\Controller\Admin\FeatureAvController::updateAction + + + + Thelia\Controller\Admin\FeatureAvController::processUpdateAction + + + + Thelia\Controller\Admin\FeatureAvController::deleteAction + + + + Thelia\Controller\Admin\FeatureAvController::updatePositionAction + + + + + + + + Thelia\Controller\Admin\ModuleController::indexAction + + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index 38afb7d7f..5b26a6ed6 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -97,9 +97,9 @@ Thelia\Controller\Front\DefaultController::noAction cart + Thelia\Controller\Front\CartController::addItem - cart @@ -115,9 +115,33 @@ - - Thelia\Controller\Front\DeliveryController::select - \d+ + + Thelia\Controller\Front\OrderController::deliver + order_delivery + + + + Thelia\Controller\Front\DefaultController::noAction + order_delivery + + + + Thelia\Controller\Front\OrderController::invoice + order_invoice + + + + Thelia\Controller\Front\DefaultController::noAction + order_invoice + + + + Thelia\Controller\Front\OrderController::pay + + + + Thelia\Controller\Front\OrderController::orderPlaced + order_placed diff --git a/core/lib/Thelia/Config/Resources/routing/install.xml b/core/lib/Thelia/Config/Resources/routing/install.xml deleted file mode 100644 index d53763948..000000000 --- a/core/lib/Thelia/Config/Resources/routing/install.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - Thelia\Controller\Install\InstallController::index - - - - Thelia\Controller\Install\InstallController::checkPermission - - - diff --git a/core/lib/Thelia/Constraint/ConstraintFactory.php b/core/lib/Thelia/Constraint/ConstraintFactory.php index e96509172..e13d1d2aa 100644 --- a/core/lib/Thelia/Constraint/ConstraintFactory.php +++ b/core/lib/Thelia/Constraint/ConstraintFactory.php @@ -25,6 +25,7 @@ namespace Thelia\Constraint; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Thelia\Constraint\Rule\AvailableForEveryoneManager; use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Constraint\Rule\SerializableRule; @@ -74,11 +75,22 @@ class ConstraintFactory */ public function serializeCouponRuleCollection(CouponRuleCollection $collection) { + if ($collection->isEmpty()) { + /** @var CouponRuleInterface $ruleNoCondition */ + $ruleNoCondition = $this->container->get( + 'thelia.constraint.rule.available_for_everyone' + ); + $collection->add($ruleNoCondition); + } $serializableRules = array(); $rules = $collection->getRules(); if ($rules !== null) { /** @var $rule CouponRuleInterface */ foreach ($rules as $rule) { + // Remove all rule if the "no condition" rule is found +// if ($rule->getServiceId() == 'thelia.constraint.rule.available_for_everyone') { +// return base64_encode(json_encode(array($rule->getSerializableRule()))); +// } $serializableRules[] = $rule->getSerializableRule(); } } diff --git a/core/lib/Thelia/Constraint/ConstraintValidator.php b/core/lib/Thelia/Constraint/ConstraintValidator.php index edacee317..d3fe69a34 100644 --- a/core/lib/Thelia/Constraint/ConstraintValidator.php +++ b/core/lib/Thelia/Constraint/ConstraintValidator.php @@ -52,7 +52,7 @@ class ConstraintValidator * * @return bool */ - public function test(CouponRuleCollection $rules) + public function isMatching(CouponRuleCollection $rules) { $isMatching = true; /** @var CouponRuleInterface $rule */ @@ -69,10 +69,10 @@ class ConstraintValidator /** * Do variable comparison * - * @param mixed $v1 Variable 1 + * @param mixed $v1 Variable 1 * @param string $o Operator + * @param mixed $v2 Variable 2 * - * @param mixed $v2 Variable 2 * @throws \Exception * @return bool */ diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php index 9f1bf23a0..30bc86ad6 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php @@ -25,7 +25,6 @@ namespace Thelia\Constraint\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Symfony\Component\Translation\Translator; -use Thelia\Constraint\ConstraintValidator; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\RuleValidator; @@ -168,13 +167,12 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract return false; } - $constrainValidator = new ConstraintValidator(); - $constraint1 =$constrainValidator->variableOpComparison( + $constraint1 = $this->constraintValidator->variableOpComparison( $this->adapter->getCartTotalPrice(), $this->operators[self::INPUT1], $this->values[self::INPUT1] ); - $constraint2 =$constrainValidator->variableOpComparison( + $constraint2 = $this->constraintValidator->variableOpComparison( $this->adapter->getCheckoutCurrency(), $this->operators[self::INPUT2], $this->values[self::INPUT2] diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php index 26c7a8aeb..572d39b1d 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php @@ -126,8 +126,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract */ public function isMatching() { - $constrainValidator = new ConstraintValidator(); - $constraint1 =$constrainValidator->variableOpComparison( + $constraint1 = $this->constraintValidator->variableOpComparison( $this->adapter->getNbArticlesInCart(), $this->operators[self::INPUT1], $this->values[self::INPUT1] diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php index 1cab6c48b..0986daa50 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php @@ -24,6 +24,7 @@ namespace Thelia\Constraint\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; +use Thelia\Constraint\ConstraintValidator; use Thelia\Core\Translation\Translator; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Constraint\Validator\ComparableInterface; @@ -73,6 +74,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** @var array Values set by Admin in BackOffice */ protected $values = array(); + /** @var ConstraintValidator Constaints validator */ + protected $constraintValidator = null; + /** * Constructor * @@ -82,6 +86,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface { $this->adapter = $adapter; $this->translator = $adapter->getTranslator(); + $this->constraintValidator = $adapter->getConstraintValidator(); } // /** diff --git a/core/lib/Thelia/Constraint/Rule/Operators.php b/core/lib/Thelia/Constraint/Rule/Operators.php index 41640810c..2ed5c2909 100644 --- a/core/lib/Thelia/Constraint/Rule/Operators.php +++ b/core/lib/Thelia/Constraint/Rule/Operators.php @@ -133,21 +133,21 @@ abstract class Operators break; case self::INFERIOR_OR_EQUAL: $ret = $translator->trans( - 'inferior or equals to', + 'inferior or equal to', array(), 'constraint' ); break; case self::EQUAL: $ret = $translator->trans( - 'equals to', + 'equal to', array(), 'constraint' ); break; case self::SUPERIOR_OR_EQUAL: $ret = $translator->trans( - 'superior or equals to', + 'superior or equal to', array(), 'constraint' ); diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 31f9ba72a..a86f55b13 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -210,31 +210,45 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object creation processing if required. * - * @param unknown $createdObject the created object + * @param unknown $createEvent the create event + * @return Response a response, or null to continue normal processing */ - protected function performAdditionalCreateAction($createdObject) + protected function performAdditionalCreateAction($createEvent) { - // Nothing to do + return null; } /** * Put in this method post object update processing if required. * - * @param unknown $updatedObject the updated object + * @param unknown $updateEvent the update event + * @return Response a response, or null to continue normal processing */ - protected function performAdditionalUpdateAction($updatedObject) + protected function performAdditionalUpdateAction($updateEvent) { - // Nothing to do + return null; } /** * Put in this method post object delete processing if required. * - * @param unknown $deletedObject the deleted object + * @param unknown $deleteEvent the delete event + * @return Response a response, or null to continue normal processing */ - protected function performAdditionalDeleteAction($deletedObject) + protected function performAdditionalDeleteAction($deleteEvent) { - // Nothing to do + return null; + } + + /** + * Put in this method post object position change processing if required. + * + * @param unknown $deleteEvent the delete event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdatePositionAction($positionChangeEvent) + { + return null; } /** @@ -306,14 +320,18 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend(sprintf("%s %s (ID %s) created", ucfirst($this->objectName), $this->getObjectLabel($createdObject), $this->getObjectId($createdObject))); } - $this->performAdditionalCreateAction($createdObject); + $response = $this->performAdditionalCreateAction($createEvent); - // Substitute _ID_ in the URL with the ID of the created object - $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); - - // Redirect to the success URL - $this->redirect($successUrl); + if ($response == null) { + // Substitute _ID_ in the URL with the ID of the created object + $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); + // Redirect to the success URL + $this->redirect($successUrl); + } + else { + return $response; + } } catch (FormValidationException $ex) { // Form cannot be validated @@ -393,16 +411,21 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject))); } - $this->performAdditionalUpdateAction($changedObject); + $response = $this->performAdditionalUpdateAction($changeEvent); - // If we have to stay on the same page, do not redirect to the succesUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToEditionTemplate($this->getRequest()); + if ($response == null) { + // If we have to stay on the same page, do not redirect to the succesUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($changeForm->getSuccessUrl()); + } + else { + return $response; } - - // Redirect to the success URL - $this->redirect($changeForm->getSuccessUrl()); } catch (FormValidationException $ex) { // Form cannot be validated @@ -449,7 +472,14 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToListTemplate(); + $response = $this->performAdditionalUpdatePositionAction($event); + + if ($response == null) { + $this->redirectToListTemplate(); + } + else { + return $response; + } } /** @@ -462,9 +492,6 @@ abstract class AbstractCrudController extends BaseAdminController $changeEvent = $this->createToggleVisibilityEvent($this->getRequest()); - // Create and dispatch the change event - $changeEvent->setIsDefault(true); - try { $this->dispatch($this->visibilityToggleEventIdentifier, $changeEvent); } catch (\Exception $ex) { @@ -472,7 +499,7 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); + return $this->nullResponse(); } /** @@ -494,8 +521,12 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend( sprintf("%s %s (ID %s) deleted", ucfirst($this->objectName), $this->getObjectLabel($deletedObject), $this->getObjectId($deletedObject))); } - $this->performAdditionalDeleteAction($deletedObject); - $this->redirectToListTemplate(); + $response = $this->performAdditionalDeleteAction($deleteEvent); + + if ($response == null) + $this->redirectToListTemplate(); + else + return $response; } } diff --git a/core/lib/Thelia/Controller/Admin/AdminController.php b/core/lib/Thelia/Controller/Admin/AdminController.php index fdb6b13ac..2d3d80df1 100755 --- a/core/lib/Thelia/Controller/Admin/AdminController.php +++ b/core/lib/Thelia/Controller/Admin/AdminController.php @@ -23,10 +23,19 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\Security\Authentication\AdminTokenAuthenticator; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Security\Exception\TokenAuthenticationException; + class AdminController extends BaseAdminController { public function indexAction() { return $this->render("home"); } + + public function updateAction() + { + return $this->render("profile-edit"); + } } diff --git a/core/lib/Thelia/Controller/Admin/AttributeAvController.php b/core/lib/Thelia/Controller/Admin/AttributeAvController.php index b3afa687d..1ab12a081 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeAvController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeAvController.php @@ -33,7 +33,7 @@ use Thelia\Form\AttributeAvCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages attributes-av sent by mail + * Manages attributes-av * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index 0ae181900..48a65baa7 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -37,7 +37,7 @@ use Thelia\Core\Event\AttributeAvUpdateEvent; use Thelia\Core\Event\AttributeEvent; /** - * Manages attributes sent by mail + * Manages attributes * * @author Franck Allimant */ @@ -107,7 +107,7 @@ class AttributeController extends AbstractCrudController * * @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction() */ - protected function performAdditionalUpdateAction($updatedObject) + protected function performAdditionalUpdateAction($updateEvent) { $attr_values = $this->getRequest()->get('attribute_values', null); @@ -123,6 +123,8 @@ class AttributeController extends AbstractCrudController $this->dispatch(TheliaEvents::ATTRIBUTE_AV_UPDATE, $event); } } + + return null; } protected function createUpdatePositionEvent($positionChangeMode, $positionValue) diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 6471dda81..1e0f65055 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -40,6 +40,8 @@ use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; use Thelia\Log\Tlog; use Symfony\Component\Routing\Router; +use Thelia\Model\Admin; +use Thelia\Core\Security\Token\CookieTokenProvider; class BaseAdminController extends BaseController { @@ -302,6 +304,46 @@ class BaseAdminController extends BaseController return $order; } + /** + * Create the remember me cookie for the given user. + */ + protected function createAdminRememberMeCookie(Admin $user) + { + $ctp = new CookieTokenProvider(); + + $cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn'); + $cookieExpiration = ConfigQuery::read('admin_remember_me_cookie_expiration', 2592000 /* 1 month */); + + $ctp->createCookie($user, $cookieName, $cookieExpiration); + } + + /** + * Get the rememberme key from the cookie. + * + * @return string hte key found, or null if no key was found. + */ + protected function getRememberMeKeyFromCookie() + { + // Check if we can authenticate the user with a cookie-based token + $cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn'); + + $ctp = new CookieTokenProvider(); + + return $ctp->getKeyFromCookie($this->getRequest(), $cookieName); + } + + /** Clear the remember me cookie. + * + */ + protected function clearRememberMeCookie() { + + $ctp = new CookieTokenProvider(); + + $cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn'); + + $ctp->clearCookie($cookieName); + } + /** * Render the given template, and returns the result as an Http Response. * diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index fba832ec8..4d0d15ef1 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -23,226 +23,178 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CategoryCreateEvent; -use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\CategoryDeleteEvent; -use Thelia\Core\Event\CategoryUpdatePositionEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryUpdateEvent; +use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; +use Thelia\Form\CategoryCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\FolderQuery; +use Thelia\Model\ContentQuery; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\CategoryAssociatedContentQuery; -class CategoryController extends BaseAdminController +/** + * Manages categories + * + * @author Franck Allimant + */ +class CategoryController extends AbstractCrudController { - /** - * Render the categories list, ensuring the sort order is set. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - protected function renderList() - { - return $this->render('categories', $this->getTemplateArgs()); + public function __construct() { + parent::__construct( + 'category', + 'manual', + 'category_order', + + 'admin.categories.default', + 'admin.categories.create', + 'admin.categories.update', + 'admin.categories.delete', + + TheliaEvents::CATEGORY_CREATE, + TheliaEvents::CATEGORY_UPDATE, + TheliaEvents::CATEGORY_DELETE, + TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, + TheliaEvents::CATEGORY_UPDATE_POSITION + ); } - protected function getTemplateArgs() - { - // Get the category ID - $category_id = $this->getRequest()->get('category_id', 0); + protected function getCreationForm() { + return new CategoryCreationForm($this->getRequest()); + } - // Find the current category order - $category_order = $this->getRequest()->get( - 'order', - $this->getSession()->get('admin.category_order', 'manual') + protected function getUpdateForm() { + return new CategoryModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) { + $createEvent = new CategoryCreateEvent(); + + $createEvent + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ->setParent($formData['parent']) + ->setVisible($formData['visible']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) { + $changeEvent = new CategoryUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setParent($formData['parent']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { + + return new UpdatePositionEvent( + $this->getRequest()->get('category_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() { + return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0)); + } + + protected function eventContainsObject($event) { + return $event->hasCategory(); + } + + protected function hydrateObjectForm($object) { + + // Prepare the data that will hydrate the form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum(), + 'visible' => $object->getVisible(), + 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), + 'parent' => $object->getParent() ); - $args = array( - 'current_category_id' => $category_id, - 'category_order' => $category_order, + // Setup the object form + return new CategoryModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) { + return $event->hasCategory() ? $event->getCategory() : null; + } + + protected function getExistingObject() { + return CategoryQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('category_id', 0)); + } + + protected function getObjectLabel($object) { + return $object->getTitle(); + } + + protected function getObjectId($object) { + return $object->getId(); + } + + protected function getEditionArguments() + { + return array( + 'category_id' => $this->getRequest()->get('category_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') ); - - // Store the current sort order in session - $this->getSession()->set('admin.category_order', $category_order); - - return $args; } - /** - * The default action is displaying the categories list. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function defaultAction() - { - if (null !== $response = $this->checkAuth("admin.categories.view")) return $response; - return $this->renderList(); + protected function renderListTemplate($currentOrder) { + + // Get product order + $product_order = $this->getListOrderFromSession('product', 'product_order', 'manual'); + + return $this->render('categories', + array( + 'category_order' => $currentOrder, + 'product_order' => $product_order, + 'category_id' => $this->getRequest()->get('category_id', 0) + )); } - /** - * Create a new category object - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function createAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.create")) return $response; - - $error_msg = false; - - // Create the Creation Form - $creationForm = new CategoryCreationForm($this->getRequest()); - - try { - - // Validate the form, create the CategoryCreation event and dispatch it. - $form = $this->validateForm($creationForm, "POST"); - - $data = $form->getData(); - - $createEvent = new CategoryCreateEvent( - $data["title"], - $data["parent"], - $data["locale"] - ); - - $this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent); - - if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created.")); - - $createdObject = $createEvent->getCategory(); - - // Log category creation - $this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getTitle(), $createdObject->getId())); - - // Substitute _ID_ in the URL with the ID of the created object - $successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl()); - - // Redirect to the success URL - $this->redirect($successUrl); - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any other error - $error_msg = $ex->getMessage(); - } - - $this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex); - - // At this point, the form has error, and should be redisplayed. - return $this->renderList(); + protected function redirectToListTemplate() { + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getRequest()->get('category_id', 0)) + ); } - /** - * Load a category object for modification, and display the edit template. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function changeAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; + protected function renderEditionTemplate() { - // Load the category object - $category = CategoryQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) - ->findOneById($this->getRequest()->get('category_id')); - - if ($category != null) { - - // Prepare the data that will hydrate the form - $data = array( - 'id' => $category->getId(), - 'locale' => $category->getLocale(), - 'title' => $category->getTitle(), - 'chapo' => $category->getChapo(), - 'description' => $category->getDescription(), - 'postscriptum' => $category->getPostscriptum(), - 'parent' => $category->getParent(), - 'visible' => $category->getVisible() ? true : false, - 'url' => $category->getUrl($this->getCurrentEditionLocale()) - // tbc !!! - ); - - // Setup the object form - $changeForm = new CategoryModificationForm($this->getRequest(), "form", $data); - - // Pass it to the parser - $this->getParserContext()->addForm($changeForm); - } - - // Render the edition template. - return $this->render('category-edit', $this->getTemplateArgs()); + return $this->render('category-edit', $this->getEditionArguments()); } - /** - * Save changes on a modified category object, and either go back to the category list, or stay on the edition page. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function saveChangeAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - - $error_msg = false; - - // Create the form from the request - $changeForm = new CategoryModificationForm($this->getRequest()); - - // Get the category ID - $category_id = $this->getRequest()->get('category_id'); - - try { - - // Check the form against constraints violations - $form = $this->validateForm($changeForm, "POST"); - - // Get the form field values - $data = $form->getData(); - - $changeEvent = new CategoryUpdateEvent($data['id']); - - // Create and dispatch the change event - $changeEvent - ->setCategoryName($data['name']) - ->setLocale($data["locale"]) - ->setSymbol($data['symbol']) - ->setCode($data['code']) - ->setRate($data['rate']) - ; - - $this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent); - - if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was updated.")); - - // Log category modification - $changedObject = $changeEvent->getCategory(); - - $this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getTitle(), $changedObject->getId())); - - // If we have to stay on the same page, do not redirect to the succesUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToRoute( - "admin.categories.update", - array('category_id' => $category_id) - ); - } - - // Redirect to the success URL - $this->redirect($changeForm->getSuccessUrl()); - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any other error - $error_msg = $ex->getMessage(); - } - - $this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex); - - // At this point, the form has errors, and should be redisplayed. - return $this->render('category-edit', array('category_id' => $category_id)); + protected function redirectToEditionTemplate() { + $this->redirectToRoute("admin.categories.update", $this->getEditionArguments()); } /** @@ -253,74 +205,130 @@ class CategoryController extends BaseAdminController // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - $changeEvent = new CategoryUpdateEvent($this->getRequest()->get('category_id', 0)); - - // Create and dispatch the change event - $changeEvent->setIsDefault(true); + $event = new CategoryToggleVisibilityEvent($this->getExistingObject()); try { - $this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent); + $this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event); } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); + // Ajax response -> no action + return $this->nullResponse(); } - /** - * Update categoryposition - */ - public function updatePositionAction() + protected function performAdditionalDeleteAction($deleteEvent) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $deleteEvent->getCategory()->getParent()) + ); + } + + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $updateEvent->getCategory()->getParent()) + ); + } + } + + protected function performAdditionalUpdatePositionAction($event) + { + + $category = CategoryQuery::create()->findPk($event->getObjectId()); + + if ($category != null) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $category->getParent()) + ); + } + + return null; + } + + public function getAvailableRelatedContentAction($categoryId, $folderId) { + + $result = array(); + + $folders = FolderQuery::create()->filterById($folderId)->find(); + + if ($folders !== null) { + + $list = ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFolder($folders, Criteria::IN) + ->filterById(CategoryAssociatedContentQuery::create()->select('content_id')->findByCategoryId($categoryId), Criteria::NOT_IN) + ->find(); + ; + + if ($list !== null) { + foreach($list as $item) { + $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addRelatedContentAction() { + // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - try { - $mode = $this->getRequest()->get('mode', null); + $content_id = intval($this->getRequest()->get('content_id')); - if ($mode == 'up') - $mode = CategoryUpdatePositionEvent::POSITION_UP; - else if ($mode == 'down') - $mode = CategoryUpdatePositionEvent::POSITION_DOWN; - else - $mode = CategoryUpdatePositionEvent::POSITION_ABSOLUTE; + if ($content_id > 0) { - $position = $this->getRequest()->get('position', null); - - $event = new CategoryUpdatePositionEvent( - $this->getRequest()->get('category_id', null), - $mode, - $this->getRequest()->get('position', null) + $event = new CategoryAddContentEvent( + $this->getExistingObject(), + $content_id ); - $this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event); - } catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); + try { + $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } } - $this->redirectToRoute('admin.categories.default'); + $this->redirectToEditionTemplate(); } - /** - * Delete a category object - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function deleteAction() - { + public function deleteRelatedContentAction() { + // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response; + if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - // Get the category id, and dispatch the deleted request - $event = new CategoryDeleteEvent($this->getRequest()->get('category_id')); + $content_id = intval($this->getRequest()->get('content_id')); - $this->dispatch(TheliaEvents::CATEGORY_DELETE, $event); + if ($content_id > 0) { - if ($event->hasCategory()) - $this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $event->getCategory()->getTitle(), $event->getCategory()->getId())); + $event = new CategoryDeleteContentEvent( + $this->getExistingObject(), + $content_id + ); - $this->redirectToRoute('admin.categories.default'); + try { + $this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); } } diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index ff0e4bb39..8701710b0 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -33,7 +33,7 @@ use Thelia\Form\ConfigCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages variables sent by mail + * Manages variables * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php new file mode 100644 index 000000000..9d20830a8 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -0,0 +1,289 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; +use Thelia\Core\Event\Content\ContentCreateEvent; +use Thelia\Core\Event\Content\ContentUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Form\ContentCreationForm; +use Thelia\Form\ContentModificationForm; +use Thelia\Model\ContentQuery; + + +/** + * Class ContentController + * @package Thelia\Controller\Admin + * @author manuel raynaud + */ +class ContentController extends AbstractCrudController +{ + + public function __construct() + { + parent::__construct( + 'content', + 'manual', + 'content_order', + + 'admin.content.default', + 'admin.content.create', + 'admin.content.update', + 'admin.content.delete', + + TheliaEvents::CONTENT_CREATE, + TheliaEvents::CONTENT_UPDATE, + TheliaEvents::CONTENT_DELETE, + TheliaEvents::CONTENT_TOGGLE_VISIBILITY, + TheliaEvents::CONTENT_UPDATE_POSITION + ); + } + + /** + * Return the creation form for this object + */ + protected function getCreationForm() + { + return new ContentCreationForm($this->getRequest()); + } + + /** + * Return the update form for this object + */ + protected function getUpdateForm() + { + return new ContentModificationForm($this->getRequest()); + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * + * @param \Thelia\Form\ContentModificationForm $object + */ + protected function hydrateObjectForm($object) + { + // Prepare the data that will hydrate the form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum(), + 'visible' => $object->getVisible(), + 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), + ); + + // Setup the object form + return new ContentModificationForm($this->getRequest(), "form", $data); + } + + /** + * Creates the creation event with the provided form data + * + * @param unknown $formData + */ + protected function getCreationEvent($formData) + { + $contentCreateEvent = new ContentCreateEvent(); + + $contentCreateEvent + ->setLocale($formData['locale']) + ->setDefaultFolder($formData['default_folder']) + ->setTitle($formData['title']) + ->setVisible($formData['visible']) + ; + + return $contentCreateEvent; + } + + /** + * Creates the update event with the provided form data + * + * @param unknown $formData + */ + protected function getUpdateEvent($formData) + { + $contentUpdateEvent = new ContentUpdateEvent($formData['id']); + + $contentUpdateEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setDefaultFolder($formData['default_folder']); + + return $contentUpdateEvent; + } + + /** + * Creates the delete event with the provided form data + */ + protected function getDeleteEvent() + { + // TODO: Implement getDeleteEvent() method. + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * + * @param \Thelia\Core\Event\Content\ContentEvent $event + */ + protected function eventContainsObject($event) + { + return $event->hasContent(); + } + + /** + * Get the created object from an event. + * + * @param $event \Thelia\Core\Event\Content\ContentEvent + * + * @return null|\Thelia\Model\Content + */ + protected function getObjectFromEvent($event) + { + return $event->getContent(); + } + + /** + * Load an existing object from the database + * + * @return \Thelia\Model\Content + */ + protected function getExistingObject() + { + return ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('content_id', 0)); + } + + /** + * Returns the object label form the object event (name, title, etc.) + * + * @param $object \Thelia\Model\Content + * + * @return string content title + * + */ + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + /** + * Returns the object ID from the object + * + * @param $object \Thelia\Model\Content + * + * @return int content id + */ + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getFolderId() + { + $folderId = $this->getRequest()->get('folder_id', null); + + if(null === $folderId) { + $content = $this->getExistingObject(); + + if($content) { + $folderId = $content->getDefaultFolderId(); + } + } + + return $folderId ?: 0; + } + + /** + * Render the main list template + * + * @param unknown $currentOrder, if any, null otherwise. + */ + protected function renderListTemplate($currentOrder) + { + $this->getListOrderFromSession('content', 'content_order', 'manual'); + + return $this->render('folders', + array( + 'content_order' => $currentOrder, + 'parent' => $this->getFolderId() + )); + } + + protected function getEditionArguments() + { + return array( + 'content_id' => $this->getRequest()->get('content_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); + } + + /** + * Render the edition template + */ + protected function renderEditionTemplate() + { + return $this->render('content-edit', $this->getEditionArguments()); + } + + /** + * Redirect to the edition template + */ + protected function redirectToEditionTemplate() + { + $this->redirect($this->getRoute('admin.content.update', $this->getEditionArguments())); + } + + /** + * Redirect to the list template + */ + protected function redirectToListTemplate() + { + $this->redirectToRoute( + 'admin.content.default', + array('parent' => $this->getFolderId()) + ); + } + + /** + * @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent + * @return Response|void + */ + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $this->getFolderId()) + ); + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Front/DeliveryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php similarity index 72% rename from core/lib/Thelia/Controller/Front/DeliveryController.php rename to core/lib/Thelia/Controller/Admin/CountryController.php index ef5913bc9..fadca1e92 100644 --- a/core/lib/Thelia/Controller/Front/DeliveryController.php +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -21,35 +21,32 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Front; -use Thelia\Model\ModuleQuery; -use Thelia\Tools\URL; +namespace Thelia\Controller\Admin; /** - * Class DeliveryController - * @package Thelia\Controller\Front + * Class CustomerController + * @package Thelia\Controller\Admin * @author Manuel Raynaud */ -class DeliveryController extends BaseFrontController +class CountryController extends BaseAdminController { - public function select($delivery_id) + public function indexAction() { - if ($this->getSecurityContext()->hasCustomerUser() === false) { - $this->redirect(URL::getInstance()->getIndexPage()); - } - - $request = $this->getRequest(); - - $deliveryModule = ModuleQuery::create() - ->filterById($delivery_id) - ->filterByActivate(1) - ->findOne() - ; - - if ($deliveryModule) { - $request->getSession()->setDelivery($delivery_id); - } else { - $this->pageNotFound(); - } + if (null !== $response = $this->checkAuth("admin.country.view")) return $response; + return $this->render("countries", array("display_country" => 20)); } -} + + /** + * update country action + * + * @param $country_id + * @return mixed|\Symfony\Component\HttpFoundation\Response + */ + public function updateAction($country_id) + { + return $this->render("country-edit", array( + "country_id" => $country_id + )); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index cd8521d7a..6803addfd 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -30,6 +30,7 @@ use Thelia\Constraint\ConstraintFactoryTest; use Thelia\Constraint\Rule\AvailableForTotalAmount; use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Constraint\Validator\PriceParam; +use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponEvent; @@ -39,6 +40,7 @@ use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Core\Translation\Translator; use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\CouponFactory; use Thelia\Coupon\CouponManager; use Thelia\Coupon\CouponRuleCollection; use Thelia\Coupon\Type\CouponInterface; @@ -72,7 +74,54 @@ class CouponController extends BaseAdminController { $this->checkAuth('ADMIN', 'admin.coupon.view'); - return $this->render('coupon-list'); + $args['urlReadCoupon'] = $this->getRoute( + 'admin.coupon.read', + array('couponId' => 'couponId'), + Router::ABSOLUTE_URL + ); + + $args['urlEditCoupon'] = $this->getRoute( + 'admin.coupon.update', + array('couponId' => 'couponId'), + Router::ABSOLUTE_URL + ); + + $args['urlCreateCoupon'] = $this->getRoute( + 'admin.coupon.create', + array(), + Router::ABSOLUTE_URL + ); + + return $this->render('coupon-list', $args); + } + + /** + * Manage Coupons read display + * + * @param int $couponId Coupon Id + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function readAction($couponId) + { + $this->checkAuth('ADMIN', 'admin.coupon.read'); + + // Database request repeated in the loop but cached + $search = CouponQuery::create(); + $coupon = $search->findOneById($couponId); + + if ($coupon === null) { + return $this->pageNotFound(); + } + + $args['couponId'] = $couponId; + $args['urlEditCoupon'] = $this->getRoute( + 'admin.coupon.update', + array('couponId' => $couponId), + Router::ABSOLUTE_URL + ); + + return $this->render('coupon-read', $args); } /** @@ -93,7 +142,7 @@ class CouponController extends BaseAdminController $i18n = new I18n(); /** @var Lang $lang */ - $lang = $this->getSession()->get('lang'); + $lang = $this->getSession()->getLang(); $eventToDispatch = TheliaEvents::COUPON_CREATE; if ($this->getRequest()->isMethod('POST')) { @@ -108,10 +157,12 @@ class CouponController extends BaseAdminController // If no input for expirationDate, now + 2 months $defaultDate = new \DateTime(); $args['defaultDate'] = $defaultDate->modify('+2 month') - ->format($lang->getDateFormat()); + ->format('Y-m-d'); } - $args['formAction'] = 'admin/coupon/create'; + $args['dateFormat'] = $this->getSession()->getLang()->getDateFormat(); + $args['availableCoupons'] = $this->getAvailableCoupons(); + $args['formAction'] = 'admin/coupon/create/'; return $this->render( 'coupon-create', @@ -135,7 +186,7 @@ class CouponController extends BaseAdminController } /** @var Coupon $coupon */ - $coupon = CouponQuery::create()->findOneById($couponId); + $coupon = CouponQuery::create()->findPk($couponId); if (!$coupon) { $this->pageNotFound(); } @@ -148,6 +199,7 @@ class CouponController extends BaseAdminController $lang = $this->getSession()->getLang(); $eventToDispatch = TheliaEvents::COUPON_UPDATE; + // Create if ($this->getRequest()->isMethod('POST')) { $this->validateCreateOrUpdateForm( $i18n, @@ -156,9 +208,9 @@ class CouponController extends BaseAdminController 'updated', 'update' ); - } else { - // Prepare the data that will hydrate the form + } else { // Update + // Prepare the data that will hydrate the form /** @var ConstraintFactory $constraintFactory */ $constraintFactory = $this->container->get('thelia.constraint.factory'); $rules = $constraintFactory->unserializeCouponRuleCollection( @@ -173,7 +225,7 @@ class CouponController extends BaseAdminController 'shortDescription' => $coupon->getShortDescription(), 'description' => $coupon->getDescription(), 'isEnabled' => ($coupon->getIsEnabled() == 1), - 'expirationDate' => $coupon->getExpirationDate($lang->getDateFormat()), + 'expirationDate' => $coupon->getExpirationDate('Y-m-d'), 'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1), 'isCumulative' => ($coupon->getIsCumulative() == 1), 'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1), @@ -202,7 +254,7 @@ class CouponController extends BaseAdminController // Pass it to the parser $this->getParserContext()->addForm($changeForm); } - + $args['couponCode'] = $coupon->getCode(); $args['availableCoupons'] = $this->getAvailableCoupons(); $args['availableRules'] = $this->getAvailableRules(); $args['urlAjaxGetRuleInput'] = $this->getRoute( @@ -222,123 +274,6 @@ class CouponController extends BaseAdminController return $this->render('coupon-update', $args); } - -// /** -// * Manage Coupons Rule creation display -// * -// * @param int $couponId Coupon id -// * -// * @return \Symfony\Component\HttpFoundation\Response -// */ -// public function createRuleAction($couponId) -// { -// // Check current user authorization -// $response = $this->checkAuth('admin.coupon.update'); -// if ($response !== null) { -// return $response; -// } -// -// /** @var Coupon $coupon */ -// $coupon = CouponQuery::create()->findOneById($couponId); -// if (!$coupon) { -// $this->pageNotFound(); -// } -// -// // Parameters given to the template -// $args = array(); -// -// $i18n = new I18n(); -// /** @var Lang $lang */ -// $lang = $this->getSession()->get('lang'); -// $eventToDispatch = TheliaEvents::COUPON_RULE_CREATE; -// -// if ($this->getRequest()->isMethod('POST')) { -// $this->validateCreateOrUpdateForm( -// $i18n, -// $lang, -// $eventToDispatch, -// 'updated', -// 'update' -// ); -// } else { -// // Prepare the data that will hydrate the form -// -// /** @var ConstraintFactory $constraintFactory */ -// $constraintFactory = $this->container->get('thelia.constraint.factory'); -// -// $data = array( -// 'code' => $coupon->getCode(), -// 'title' => $coupon->getTitle(), -// 'amount' => $coupon->getAmount(), -// 'effect' => $coupon->getType(), -// 'shortDescription' => $coupon->getShortDescription(), -// 'description' => $coupon->getDescription(), -// 'isEnabled' => ($coupon->getIsEnabled() == 1), -// 'expirationDate' => $coupon->getExpirationDate($lang->getDateFormat()), -// 'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1), -// 'isCumulative' => ($coupon->getIsCumulative() == 1), -// 'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1), -// 'maxUsage' => $coupon->getMaxUsage(), -// 'rules' => $constraintFactory->unserializeCouponRuleCollection($coupon->getSerializedRules()), -// 'locale' => $coupon->getLocale(), -// ); -// -// /** @var CouponAdapterInterface $adapter */ -// $adapter = $this->container->get('thelia.adapter'); -// /** @var Translator $translator */ -// $translator = $this->container->get('thelia.translator'); -// -// $args['rulesObject'] = array(); -// /** @var CouponRuleInterface $rule */ -// foreach ($coupon->getRules()->getRules() as $rule) { -// $args['rulesObject'][] = array( -// 'name' => $rule->getName($translator), -// 'tooltip' => $rule->getToolTip($translator), -// 'validators' => $rule->getValidators() -// ); -// } -// -// $args['rules'] = $this->cleanRuleForTemplate($coupon->getRules()->getRules()); -// -// // Setup the object form -// $changeForm = new CouponCreationForm($this->getRequest(), 'form', $data); -// -// // Pass it to the parser -// $this->getParserContext()->addForm($changeForm); -// } -// -// $args['formAction'] = 'admin/coupon/update/' . $couponId; -// -// return $this->render( -// 'coupon-update', -// $args -// ); -// } - - - - /** - * Manage Coupons read display - * - * @param int $couponId Coupon Id - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function readAction($couponId) - { - $this->checkAuth('ADMIN', 'admin.coupon.read'); - - // Database request repeated in the loop but cached - $search = CouponQuery::create(); - $coupon = $search->findOneById($couponId); - - if ($coupon === null) { - return $this->pageNotFound(); - } - - return $this->render('coupon-read', array('couponId' => $couponId)); - } - /** * Manage Coupons read display * @@ -350,17 +285,7 @@ class CouponController extends BaseAdminController { $this->checkAuth('ADMIN', 'admin.coupon.read'); - if ($this->isDebug()) { - if (!$this->getRequest()->isXmlHttpRequest()) { - $this->redirect( - $this->getRoute( - 'admin', - array(), - Router::ABSOLUTE_URL - ) - ); - } - } + $this->checkXmlHttpRequest(); /** @var ConstraintFactory $constraintFactory */ $constraintFactory = $this->container->get('thelia.constraint.factory'); @@ -391,17 +316,7 @@ class CouponController extends BaseAdminController { $this->checkAuth('ADMIN', 'admin.coupon.read'); - if ($this->isDebug()) { - if (!$this->getRequest()->isXmlHttpRequest()) { - $this->redirect( - $this->getRoute( - 'admin', - array(), - Router::ABSOLUTE_URL - ) - ); - } - } + $this->checkXmlHttpRequest(); $search = CouponQuery::create(); /** @var Coupon $coupon */ @@ -475,6 +390,29 @@ class CouponController extends BaseAdminController ); } + /** + * Test Coupon consuming + * + * @param string $couponCode Coupon code + * + */ + public function consumeAction($couponCode) + { + // @todo remove (event dispatcher testing purpose) + $couponConsumeEvent = new CouponConsumeEvent($couponCode); + $eventToDispatch = TheliaEvents::COUPON_CONSUME; + + // Dispatch Event to the Action + $this->dispatch( + $eventToDispatch, + $couponConsumeEvent + ); + + var_dump('test', $couponConsumeEvent->getCode(), $couponConsumeEvent->getDiscount(), $couponConsumeEvent->getIsValid()); + + exit(); + } + /** * Build a Coupon from its form * @@ -535,7 +473,7 @@ class CouponController extends BaseAdminController /** * Validate the CreateOrUpdate form * - * @param string $i18n Local code (fr_FR) + * @param I18n $i18n Local code (fr_FR) * @param Lang $lang Local variables container * @param string $eventToDispatch Event which will activate actions * @param string $log created|edited @@ -543,7 +481,7 @@ class CouponController extends BaseAdminController * * @return $this */ - protected function validateCreateOrUpdateForm($i18n, $lang, $eventToDispatch, $log, $action) + protected function validateCreateOrUpdateForm(I18n $i18n, Lang $lang, $eventToDispatch, $log, $action) { // Create the form from the request $creationForm = new CouponCreationForm($this->getRequest()); @@ -563,7 +501,7 @@ class CouponController extends BaseAdminController $data['shortDescription'], $data['description'], $data['isEnabled'], - $i18n->getDateTimeFromForm($lang, $data['expirationDate']), + \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], @@ -651,17 +589,17 @@ class CouponController extends BaseAdminController /** @var CouponManager $couponManager */ $couponManager = $this->container->get('thelia.coupon.manager'); $availableCoupons = $couponManager->getAvailableCoupons(); - $cleanedRules = array(); + $cleanedCoupons = array(); /** @var CouponInterface $availableCoupon */ foreach ($availableCoupons as $availableCoupon) { $rule = array(); $rule['serviceId'] = $availableCoupon->getServiceId(); $rule['name'] = $availableCoupon->getName(); $rule['toolTip'] = $availableCoupon->getToolTip(); - $cleanedRules[] = $rule; + $cleanedCoupons[] = $rule; } - return $cleanedRules; + return $cleanedCoupons; } /** diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 4f3fdaaea..f0081d698 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -33,7 +33,7 @@ use Thelia\Form\CurrencyCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages currencies sent by mail + * Manages currencies * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/FeatureAvController.php b/core/lib/Thelia/Controller/Admin/FeatureAvController.php new file mode 100644 index 000000000..fc6571ccc --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FeatureAvController.php @@ -0,0 +1,196 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\FeatureAvDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\FeatureAvUpdateEvent; +use Thelia\Core\Event\FeatureAvCreateEvent; +use Thelia\Model\FeatureAvQuery; +use Thelia\Form\FeatureAvModificationForm; +use Thelia\Form\FeatureAvCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; + +/** + * Manages features-av + * + * @author Franck Allimant + */ +class FeatureAvController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'featureav', + 'manual', + 'order', + + 'admin.configuration.features-av.view', + 'admin.configuration.features-av.create', + 'admin.configuration.features-av.update', + 'admin.configuration.features-av.delete', + + TheliaEvents::FEATURE_AV_CREATE, + TheliaEvents::FEATURE_AV_UPDATE, + TheliaEvents::FEATURE_AV_DELETE, + null, // No visibility toggle + TheliaEvents::FEATURE_AV_UPDATE_POSITION + ); + } + + protected function getCreationForm() + { + return new FeatureAvCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new FeatureAvModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new FeatureAvCreateEvent(); + + $createEvent + ->setFeatureId($formData['feature_id']) + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new FeatureAvUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData["locale"]) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('featureav_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() + { + return new FeatureAvDeleteEvent($this->getRequest()->get('featureav_id')); + } + + protected function eventContainsObject($event) + { + return $event->hasFeatureAv(); + } + + protected function hydrateObjectForm($object) + { + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum() + ); + + // Setup the object form + return new FeatureAvModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasFeatureAv() ? $event->getFeatureAv() : null; + } + + protected function getExistingObject() + { + return FeatureAvQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('featureav_id')); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getViewArguments() + { + return array( + 'feature_id' => $this->getRequest()->get('feature_id'), + 'order' => $this->getCurrentListOrder() + ); + } + + protected function renderListTemplate($currentOrder) + { + // We always return to the feature edition form + return $this->render( + 'feature-edit', + $this->getViewArguments() + ); + } + + protected function renderEditionTemplate() + { + // We always return to the feature edition form + return $this->render('feature-edit', $this->getViewArguments()); + } + + protected function redirectToEditionTemplate() + { + // We always return to the feature edition form + $this->redirectToRoute( + "admin.configuration.features.update", + $this->getViewArguments() + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute( + "admin.configuration.features.update", + $this->getViewArguments() + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php new file mode 100644 index 000000000..f81f55919 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -0,0 +1,289 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\FeatureDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\FeatureUpdateEvent; +use Thelia\Core\Event\FeatureCreateEvent; +use Thelia\Model\FeatureQuery; +use Thelia\Form\FeatureModificationForm; +use Thelia\Form\FeatureCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\FeatureAv; +use Thelia\Model\FeatureAvQuery; +use Thelia\Core\Event\FeatureAvUpdateEvent; +use Thelia\Core\Event\FeatureEvent; + +/** + * Manages features + * + * @author Franck Allimant + */ +class FeatureController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'feature', + 'manual', + 'order', + + 'admin.configuration.features.view', + 'admin.configuration.features.create', + 'admin.configuration.features.update', + 'admin.configuration.features.delete', + + TheliaEvents::FEATURE_CREATE, + TheliaEvents::FEATURE_UPDATE, + TheliaEvents::FEATURE_DELETE, + null, // No visibility toggle + TheliaEvents::FEATURE_UPDATE_POSITION + ); + } + + protected function getCreationForm() + { + return new FeatureCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new FeatureModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new FeatureCreateEvent(); + + $createEvent + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ->setAddToAllTemplates($formData['add_to_all']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new FeatureUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData["locale"]) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ; + + return $changeEvent; + } + + /** + * Process the features values (fix it in future version to integrate it in the feature form as a collection) + * + * @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction() + */ + protected function performAdditionalUpdateAction($updateEvent) + { + $attr_values = $this->getRequest()->get('feature_values', null); + + if ($attr_values !== null) { + + foreach($attr_values as $id => $value) { + + $event = new FeatureAvUpdateEvent($id); + + $event->setTitle($value); + $event->setLocale($this->getCurrentEditionLocale()); + + $this->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $event); + } + } + + return null; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('feature_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() + { + return new FeatureDeleteEvent($this->getRequest()->get('feature_id')); + } + + protected function eventContainsObject($event) + { + return $event->hasFeature(); + } + + protected function hydrateObjectForm($object) + { + + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum() + ); + + // Setup features values + /* + * FIXME : doesn't work. "We get a This form should not contain extra fields." error + $attr_av_list = FeatureAvQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFeatureId($object->getId()) + ->find(); + + $attr_array = array(); + + foreach($attr_av_list as $attr_av) { + $attr_array[$attr_av->getId()] = $attr_av->getTitle(); + } + + $data['feature_values'] = $attr_array; + */ + + // Setup the object form + return new FeatureModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasFeature() ? $event->getFeature() : null; + } + + protected function getExistingObject() + { + return FeatureQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('feature_id')); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function renderListTemplate($currentOrder) + { + return $this->render('features', array('order' => $currentOrder)); + } + + protected function renderEditionTemplate() + { + return $this->render( + 'feature-edit', + array( + 'feature_id' => $this->getRequest()->get('feature_id'), + 'featureav_order' => $this->getFeatureAvListOrder() + ) + ); + } + + protected function redirectToEditionTemplate() + { + $this->redirectToRoute( + "admin.configuration.features.update", + array( + 'feature_id' => $this->getRequest()->get('feature_id'), + 'featureav_order' => $this->getFeatureAvListOrder() + ) + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute('admin.configuration.features.default'); + } + + /** + * Get the Feature value list order. + * + * @return string the current list order + */ + protected function getFeatureAvListOrder() + { + return $this->getListOrderFromSession( + 'featureav', + 'featureav_order', + 'manual' + ); + } + + /** + * Add or Remove from all product templates + */ + protected function addRemoveFromAllTemplates($eventType) + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.configuration.features.update")) return $response; + + try { + if (null !== $object = $this->getExistingObject()) { + + $event = new FeatureEvent($object); + + $this->dispatch($eventType, $event); + } + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + $this->redirectToListTemplate(); + } + + /** + * Remove from all product templates + */ + public function removeFromAllTemplates() + { + return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES); + } + + /** + * Add to all product templates + */ + public function addToAllTemplates() + { + return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php new file mode 100644 index 000000000..9f2190442 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -0,0 +1,328 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; +use Thelia\Core\Event\FolderCreateEvent; +use Thelia\Core\Event\FolderDeleteEvent; +use Thelia\Core\Event\FolderToggleVisibilityEvent; +use Thelia\Core\Event\FolderUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Form\FolderCreationForm; +use Thelia\Form\FolderModificationForm; +use Thelia\Model\FolderQuery; + +/** + * Class FolderController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class FolderController extends AbstractCrudController +{ + + public function __construct() + { + parent::__construct( + 'folder', + 'manual', + 'folder_order', + + 'admin.folder.default', + 'admin.folder.create', + 'admin.folder.update', + 'admin.folder.delete', + + TheliaEvents::FOLDER_CREATE, + TheliaEvents::FOLDER_UPDATE, + TheliaEvents::FOLDER_DELETE, + TheliaEvents::FOLDER_TOGGLE_VISIBILITY, + TheliaEvents::FOLDER_UPDATE_POSITION + ); + } + + /** + * Return the creation form for this object + */ + protected function getCreationForm() + { + return new FolderCreationForm($this->getRequest()); + } + + /** + * Return the update form for this object + */ + protected function getUpdateForm() + { + return new FolderModificationForm($this->getRequest()); + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * + * @param \Thelia\Model\Folder $object + */ + protected function hydrateObjectForm($object) { + + // Prepare the data that will hydrate the form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum(), + 'visible' => $object->getVisible(), + 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), + 'parent' => $object->getParent() + ); + + // Setup the object form + return new FolderModificationForm($this->getRequest(), "form", $data); + } + + /** + * Creates the creation event with the provided form data + * + * @param unknown $formData + */ + protected function getCreationEvent($formData) + { + $creationEvent = new FolderCreateEvent(); + + $creationEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setVisible($formData['visible']) + ->setParent($formData['parent']); + + return $creationEvent; + } + + /** + * Creates the update event with the provided form data + * + * @param unknown $formData + */ + protected function getUpdateEvent($formData) + { + $updateEvent = new FolderUpdateEvent($formData['id']); + + $updateEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setParent($formData['parent']) + ; + + return $updateEvent; + } + + /** + * Creates the delete event with the provided form data + */ + protected function getDeleteEvent() + { + return new FolderDeleteEvent($this->getRequest()->get('folder_id'), 0); + } + + /** + * @return FolderToggleVisibilityEvent|void + */ + protected function createToggleVisibilityEvent() + { + return new FolderToggleVisibilityEvent($this->getExistingObject()); + } + + /** + * @param $positionChangeMode + * @param $positionValue + * @return UpdatePositionEvent|void + */ + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { + + return new UpdatePositionEvent( + $this->getRequest()->get('folder_id', null), + $positionChangeMode, + $positionValue + ); + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * + * @param \Thelia\Core\Event\FolderEvent $event + */ + protected function eventContainsObject($event) + { + return $event->hasFolder(); + } + + /** + * Get the created object from an event. + * + * @param $event \Thelia\Core\Event\FolderEvent $event + * + * @return null|\Thelia\Model\Folder + */ + protected function getObjectFromEvent($event) + { + return $event->hasFolder() ? $event->getFolder() : null; + } + + /** + * Load an existing object from the database + */ + protected function getExistingObject() { + return FolderQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('folder_id', 0)); + } + + /** + * Returns the object label form the object event (name, title, etc.) + * + * @param unknown $object + */ + protected function getObjectLabel($object) { + return $object->getTitle(); + } + + /** + * Returns the object ID from the object + * + * @param unknown $object + */ + protected function getObjectId($object) + { + return $object->getId(); + } + + /** + * Render the main list template + * + * @param unknown $currentOrder, if any, null otherwise. + */ + protected function renderListTemplate($currentOrder) { + + // Get content order + $content_order = $this->getListOrderFromSession('content', 'content_order', 'manual'); + + return $this->render('folders', + array( + 'folder_order' => $currentOrder, + 'content_order' => $content_order, + 'parent' => $this->getRequest()->get('parent', 0) + )); + } + + + /** + * Render the edition template + */ + protected function renderEditionTemplate() { + + return $this->render('folder-edit', $this->getEditionArguments()); + } + + protected function getEditionArguments() + { + return array( + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); + } + + /** + * @param \Thelia\Core\Event\FolderUpdateEvent $updateEvent + * @return Response|void + */ + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $updateEvent->getFolder()->getParent()) + ); + } + } + + /** + * Put in this method post object delete processing if required. + * + * @param \Thelia\Core\Event\FolderDeleteEvent $deleteEvent the delete event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalDeleteAction($deleteEvent) + { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $deleteEvent->getFolder()->getParent()) + ); + } + + /** + * @param $event \Thelia\Core\Event\UpdatePositionEvent + * @return null|Response + */ + protected function performAdditionalUpdatePositionAction($event) + { + + $folder = FolderQuery::create()->findPk($event->getObjectId()); + + if ($folder != null) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $folder->getParent()) + ); + } + + return null; + } + + /** + * Redirect to the edition template + */ + protected function redirectToEditionTemplate() + { + $this->redirect($this->getRoute('admin.folders.update', $this->getEditionArguments())); + } + + /** + * Redirect to the list template + */ + protected function redirectToListTemplate() + { + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $this->getRequest()->get('parent', 0)) + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php new file mode 100644 index 000000000..fe794abf9 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +/** + * Class ModuleController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class ModuleController extends BaseAdminController +{ + public function indexAction() + { + if (null !== $response = $this->checkAuth("admin.module.view")) return $response; + return $this->render("modules", array("display_module" => 20)); + } + + public function updateAction($module_id) + { + + return $this->render("module-edit", array( + "module_id" => $module_id + )); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php new file mode 100644 index 000000000..27c559442 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -0,0 +1,477 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\ProductDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\ProductUpdateEvent; +use Thelia\Core\Event\ProductCreateEvent; +use Thelia\Model\ProductQuery; +use Thelia\Form\ProductModificationForm; +use Thelia\Form\ProductCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\ProductToggleVisibilityEvent; +use Thelia\Core\Event\ProductDeleteContentEvent; +use Thelia\Core\Event\ProductAddContentEvent; +use Thelia\Model\ProductAssociatedContent; +use Thelia\Model\FolderQuery; +use Thelia\Model\ContentQuery; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\ProductAssociatedContentQuery; +use Thelia\Model\AccessoryQuery; +use Thelia\Model\CategoryQuery; +use Thelia\Core\Event\ProductAddAccessoryEvent; +use Thelia\Core\Event\ProductDeleteAccessoryEvent; + +/** + * Manages products + * + * @author Franck Allimant + */ +class ProductController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'product', + 'manual', + 'product_order', + + 'admin.products.default', + 'admin.products.create', + 'admin.products.update', + 'admin.products.delete', + + TheliaEvents::PRODUCT_CREATE, + TheliaEvents::PRODUCT_UPDATE, + TheliaEvents::PRODUCT_DELETE, + + TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, + TheliaEvents::PRODUCT_UPDATE_POSITION + ); + } + + protected function getCreationForm() + { + return new ProductCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new ProductModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new ProductCreateEvent(); + + $createEvent + ->setRef($formData['ref']) + ->setTitle($formData['title']) + ->setLocale($formData['locale']) + ->setDefaultCategory($formData['default_category']) + ->setVisible($formData['visible']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new ProductUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setParent($formData['parent']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('product_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() + { + return new ProductDeleteEvent($this->getRequest()->get('product_id', 0)); + } + + protected function eventContainsObject($event) + { + return $event->hasProduct(); + } + + protected function hydrateObjectForm($object) + { + // Prepare the data that will hydrate the form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum(), + 'visible' => $object->getVisible(), + 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), + 'default_category' => $object->getDefaultCategoryId() + ); + + // Setup the object form + return new ProductModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasProduct() ? $event->getProduct() : null; + } + + protected function getExistingObject() + { + return ProductQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('product_id', 0)); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getEditionArguments() + { + return array( + 'category_id' => $this->getCategoryId(), + 'product_id' => $this->getRequest()->get('product_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'accessory_category_id'=> $this->getRequest()->get('accessory_category_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); + } + + protected function getCategoryId() { + // Trouver le category_id, soit depuis la reques, souit depuis le produit courant + $category_id = $this->getRequest()->get('category_id', null); + + if ($category_id == null) { + $product = $this->getExistingObject(); + + if ($product !== null) $category_id = $product->getDefaultCategoryId(); + } + + return $category_id != null ? $category_id : 0; + } + + protected function renderListTemplate($currentOrder) + { + $this->getListOrderFromSession('product', 'product_order', 'manual'); + + return $this->render('categories', + array( + 'product_order' => $currentOrder, + 'category_id' => $this->getCategoryId() + )); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute( + 'admin.products.default', + array('category_id' => $this->getCategoryId()) + ); + } + + protected function renderEditionTemplate() + { + return $this->render('product-edit', $this->getEditionArguments()); + } + + protected function redirectToEditionTemplate() + { + $this->redirectToRoute("admin.products.update", $this->getEditionArguments()); + } + + /** + * Online status toggle product + */ + public function setToggleVisibilityAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $event = new ProductToggleVisibilityEvent($this->getExistingObject()); + + try { + $this->dispatch(TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + // Ajax response -> no action + return $this->nullResponse(); + } + + protected function performAdditionalDeleteAction($deleteEvent) + { + // Redirect to parent product list + $this->redirectToRoute( + 'admin.products.default', + array('category_id' => $this->getCategoryId()) + ); + } + + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent product list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getCategoryId()) + ); + } + } + + protected function performAdditionalUpdatePositionAction($positionEvent) + { + // Redirect to parent product list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getCategoryId()) + ); + } + + // -- Related content management ------------------------------------------- + + public function getAvailableRelatedContentAction($productId, $folderId) + { + $result = array(); + + $folders = FolderQuery::create()->filterById($folderId)->find(); + + if ($folders !== null) { + + $list = ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFolder($folders, Criteria::IN) + ->filterById(ProductAssociatedContentQuery::create()->select('content_id')->findByProductId($productId), Criteria::NOT_IN) + ->find(); + ; + + if ($list !== null) { + foreach($list as $item) { + $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addRelatedContentAction() + { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new ProductAddContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteRelatedContentAction() + { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new ProductDeleteContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + + // -- Accessories management ---------------------------------------------- + + public function getAvailableAccessoriesAction($productId, $categoryId) + { + $result = array(); + + $categories = CategoryQuery::create()->filterById($categoryId)->find(); + + if ($categories !== null) { + + $list = ProductQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByCategory($categories, Criteria::IN) + ->filterById(AccessoryQuery::create()->select('accessory')->findByProductId($productId), Criteria::NOT_IN) + ->find(); + ; + + if ($list !== null) { + foreach($list as $item) { + $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addAccessoryAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $accessory_id = intval($this->getRequest()->get('accessory_id')); + + if ($accessory_id > 0) { + + $event = new ProductAddAccessoryEvent( + $this->getExistingObject(), + $accessory_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteAccessoryAction() + { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $accessory_id = intval($this->getRequest()->get('accessory_id')); + + if ($accessory_id > 0) { + + $event = new ProductDeleteAccessoryEvent( + $this->getExistingObject(), + $accessory_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + /** + * Update accessory position (only for objects whichsupport that) + */ + public function updateAccessoryPositionAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth('admin.products.update')) return $response; + + try { + $mode = $this->getRequest()->get('mode', null); + + if ($mode == 'up') + $mode = UpdatePositionEvent::POSITION_UP; + else if ($mode == 'down') + $mode = UpdatePositionEvent::POSITION_DOWN; + else + $mode = UpdatePositionEvent::POSITION_ABSOLUTE; + + $position = $this->getRequest()->get('position', null); + + $event = new UpdatePositionEvent($mode, $position); + + $this->dispatch(TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + $this->redirectToEditionTemplate(); + } + +} diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index 81f366ddf..120a28b26 100755 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -30,11 +30,44 @@ use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\Authentication\AdminTokenAuthenticator; +use Thelia\Core\Security\UserProvider\TokenProvider; +use Symfony\Component\HttpFoundation\Cookie; +use Thelia\Core\Security\UserProvider\CookieTokenProvider; +use Thelia\Core\Security\Exception\TokenAuthenticationException; class SessionController extends BaseAdminController { public function showLoginAction() { + // Check if we can authenticate the user with a cookie-based token + if (null !== $key = $this->getRememberMeKeyFromCookie()) { + + // Create the authenticator + $authenticator = new AdminTokenAuthenticator($key); + + try { + // If have found a user, store it in the security context + $user = $authenticator->getAuthentifiedUser(); + + $this->getSecurityContext()->setAdminUser($user); + + $this->adminLogAppend("Successful token authentication"); + + // Update the cookie + $cookie = $this->createAdminRememberMeCookie($user); + + // Render the home page + return $this->render("home"); + } + catch (TokenAuthenticationException $ex) { + $this->adminLogAppend("Token based authentication failed."); + + // Clear the cookie + $this->clearRememberMeCookie(); + } + } + return $this->render("login"); } @@ -44,6 +77,9 @@ class SessionController extends BaseAdminController $this->getSecurityContext()->clearAdminUser(); + // Clear the remember me cookie, if any + $this->clearRememberMeCookie(); + // Go back to login page. $this->redirectToRoute('admin.login'); } @@ -68,10 +104,19 @@ class SessionController extends BaseAdminController // Log authentication success AdminLog::append("Authentication successful", $request, $user); + /** + * FIXME: we have tou find a way to send cookie + */ + if (intval($adminLoginForm->getForm()->get('remember_me')->getData()) > 0) { + // If a remember me field if present and set in the form, create + // the cookie thant store "remember me" information + $this->createAdminRememberMeCookie($user); + } + $this->dispatch(TheliaEvents::ADMIN_LOGIN); - // Redirect to the success URL - return Redirect::exec($adminLoginForm->getSuccessUrl()); + // Redirect to the success URL, passing the cookie if one exists. + $this->redirect($adminLoginForm->getSuccessUrl()); } catch (FormValidationException $ex) { diff --git a/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php b/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php new file mode 100644 index 000000000..71aa0ba2f --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +/** + * Class ShippingConfigurationController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class ShippingConfigurationController extends BaseAdminController +{ + public function indexAction() + { + if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response; + return $this->render("shipping-configuration", array("display_shipping_configuration" => 20)); + } + + public function updateAction($shipping_configuration_id) + { + + return $this->render("shipping-configuration-edit", array( + "shipping_configuration_id" => $shipping_configuration_id + )); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php new file mode 100644 index 000000000..ee34d11bd --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +/** + * Class ShippingZoneController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class ShippingZoneController extends BaseAdminController +{ + public function indexAction() + { + if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response; + return $this->render("shipping-zones", array("display_shipping_zone" => 20)); + } + + public function updateAction($shipping_zones_id) + { + + return $this->render("shipping-zones-edit", array( + "shipping_zones_id" => $shipping_zones_id + )); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/TemplateController.php b/core/lib/Thelia/Controller/Admin/TemplateController.php new file mode 100644 index 000000000..c9e30612c --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/TemplateController.php @@ -0,0 +1,302 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\TemplateDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\TemplateUpdateEvent; +use Thelia\Core\Event\TemplateCreateEvent; +use Thelia\Model\TemplateQuery; +use Thelia\Form\TemplateModificationForm; +use Thelia\Form\TemplateCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\TemplateAv; +use Thelia\Model\TemplateAvQuery; +use Thelia\Core\Event\TemplateAvUpdateEvent; +use Thelia\Core\Event\TemplateEvent; +use Thelia\Core\Event\TemplateDeleteAttributeEvent; +use Thelia\Core\Event\TemplateAddAttributeEvent; +use Thelia\Core\Event\TemplateAddFeatureEvent; +use Thelia\Core\Event\TemplateDeleteFeatureEvent; + +/** + * Manages product templates + * + * @author Franck Allimant + */ +class TemplateController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'template', + null, + null, + + 'admin.configuration.templates.view', + 'admin.configuration.templates.create', + 'admin.configuration.templates.update', + 'admin.configuration.templates.delete', + + TheliaEvents::TEMPLATE_CREATE, + TheliaEvents::TEMPLATE_UPDATE, + TheliaEvents::TEMPLATE_DELETE, + null, // No visibility toggle + null // No position update + ); + } + + protected function getCreationForm() + { + return new TemplateCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new TemplateModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new TemplateCreateEvent(); + + $createEvent + ->setTemplateName($formData['name']) + ->setLocale($formData["locale"]) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new TemplateUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData["locale"]) + ->setTemplateName($formData['name']) + ; + + // Add feature and attributes list + + return $changeEvent; + } + + protected function getDeleteEvent() + { + return new TemplateDeleteEvent($this->getRequest()->get('template_id')); + } + + protected function eventContainsObject($event) + { + return $event->hasTemplate(); + } + + protected function hydrateObjectForm($object) + { + + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'name' => $object->getName() + ); + + // Setup the object form + return new TemplateModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasTemplate() ? $event->getTemplate() : null; + } + + protected function getExistingObject() + { + return TemplateQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('template_id')); + } + + protected function getObjectLabel($object) + { + return $object->getName(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function renderListTemplate($currentOrder) + { + return $this->render('templates', array('order' => $currentOrder)); + } + + protected function renderEditionTemplate() + { + return $this->render( + 'template-edit', + array( + 'template_id' => $this->getRequest()->get('template_id'), + ) + ); + } + + protected function redirectToEditionTemplate() + { + $this->redirectToRoute( + "admin.configuration.templates.update", + array( + 'template_id' => $this->getRequest()->get('template_id'), + ) + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute('admin.configuration.templates.default'); + } + + // Process delete failure, which may occurs if template is in use. + protected function performAdditionalDeleteAction($deleteEvent) + { + if ($deleteEvent->getProductCount() > 0) { + + $this->getParserContext()->setGeneralError( + $this->getTranslator()->trans( + "This template is in use in some of your products, and cannot be deleted. Delete it from all your products and try again." + ) + ); + + return $this->renderList(); + } + + // Normal delete processing + return null; + } + + public function getAjaxFeaturesAction() { + return $this->render( + 'ajax/template-feature-list', + array('template_id' => $this->getRequest()->get('template_id')) + ); + } + + public function getAjaxAttributesAction() { + return $this->render( + 'ajax/template-attribute-list', + array('template_id' => $this->getRequest()->get('template_id')) + ); + } + + public function addAttributeAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response; + + $attribute_id = intval($this->getRequest()->get('attribute_id')); + + if ($attribute_id > 0) { + $event = new TemplateAddAttributeEvent( + $this->getExistingObject(), + $attribute_id + ); + + try { + $this->dispatch(TheliaEvents::TEMPLATE_ADD_ATTRIBUTE, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteAttributeAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response; + + $event = new TemplateDeleteAttributeEvent( + $this->getExistingObject(), + intval($this->getRequest()->get('attribute_id')) + ); + + try { + $this->dispatch(TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + $this->redirectToEditionTemplate(); + } + + public function addFeatureAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response; + + $feature_id = intval($this->getRequest()->get('feature_id')); + + if ($feature_id > 0) { + $event = new TemplateAddFeatureEvent( + $this->getExistingObject(), + $feature_id + ); + + try { + $this->dispatch(TheliaEvents::TEMPLATE_ADD_FEATURE, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteFeatureAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response; + + $event = new TemplateDeleteFeatureEvent( + $this->getExistingObject(), + intval($this->getRequest()->get('feature_id')) + ); + + try { + $this->dispatch(TheliaEvents::TEMPLATE_DELETE_FEATURE, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + $this->redirectToEditionTemplate(); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 56118635b..8ba0cb038 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -31,6 +31,7 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Router; use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Translation\Translator; use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Core\Template\ParserContext; @@ -62,6 +63,14 @@ class BaseController extends ContainerAware return new Response(); } + /** + * Return a JSON response + */ + protected function jsonResponse($json_data) + { + return new Response($json_data, 200, array('content-type' => 'application/json')); + } + /** * Dispatch a Thelia event * @@ -89,7 +98,7 @@ class BaseController extends ContainerAware * * return the Translator * - * @return mixed \Thelia\Core\Translation\Translator + * @return Translator */ public function getTranslator() { @@ -127,7 +136,7 @@ class BaseController extends ContainerAware /** * Returns the session from the current request * - * @return \Symfony\Component\HttpFoundation\Session\SessionInterface + * @return \Thelia\Core\HttpFoundation\Session\Session */ protected function getSession() { @@ -198,9 +207,9 @@ class BaseController extends ContainerAware * * @param string $url */ - public function redirect($url, $status = 302) + public function redirect($url, $status = 302, $cookies = array()) { - Redirect::exec($url, $status); + Redirect::exec($url, $status, $cookies); } /** @@ -281,4 +290,16 @@ class BaseController extends ContainerAware $this->accessDenied(); } } + + /** + * + * return an instance of \Swift_Mailer with good Transporter configured. + * + * @return \Swift_Mailer + */ + public function getMailer() + { + $mailer = $this->container->get('mailer'); + return $mailer->getSwiftMailer(); + } } diff --git a/core/lib/Thelia/Controller/Front/AddressController.php b/core/lib/Thelia/Controller/Front/AddressController.php index 272fa6424..05e3949fa 100644 --- a/core/lib/Thelia/Controller/Front/AddressController.php +++ b/core/lib/Thelia/Controller/Front/AddressController.php @@ -47,6 +47,7 @@ class AddressController extends BaseFrontController */ public function generateModalAction($address_id) { + $this->checkAuth(); $this->checkXmlHttpRequest(); @@ -62,6 +63,7 @@ class AddressController extends BaseFrontController */ public function createAction() { + $this->checkAuth(); $addressCreate = new AddressCreateForm($this->getRequest()); diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 1c4a13977..152c2c10e 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -24,6 +24,8 @@ namespace Thelia\Controller\Front; use Symfony\Component\Routing\Router; use Thelia\Controller\BaseController; +use Thelia\Model\AddressQuery; +use Thelia\Model\ModuleQuery; use Thelia\Tools\URL; class BaseFrontController extends BaseController @@ -57,4 +59,28 @@ class BaseFrontController extends BaseController $this->redirectToRoute("customer.login.view"); } } + + protected function checkCartNotEmpty() + { + $cart = $this->getSession()->getCart(); + if($cart===null || $cart->countCartItems() == 0) { + $this->redirectToRoute("cart.view"); + } + } + + protected function checkValidDelivery() + { + $order = $this->getSession()->getOrder(); + if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) { + $this->redirectToRoute("order.delivery"); + } + } + + protected function checkValidInvoice() + { + $order = $this->getSession()->getOrder(); + if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) { + $this->redirectToRoute("order.invoice"); + } + } } diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php new file mode 100755 index 000000000..1f2c716ae --- /dev/null +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -0,0 +1,246 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Controller\Front; + +use Propel\Runtime\Exception\PropelException; +use Thelia\Exception\TheliaProcessException; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Symfony\Component\HttpFoundation\Request; +use Thelia\Form\OrderDelivery; +use Thelia\Form\OrderPayment; +use Thelia\Log\Tlog; +use Thelia\Model\AddressQuery; +use Thelia\Model\AreaDeliveryModuleQuery; +use Thelia\Model\Base\OrderQuery; +use Thelia\Model\CountryQuery; +use Thelia\Model\ModuleQuery; +use Thelia\Model\Order; +use Thelia\Tools\URL; + +/** + * Class OrderController + * @package Thelia\Controller\Front + * @author Etienne Roudeix + */ +class OrderController extends BaseFrontController +{ + /** + * set delivery address + * set delivery module + */ + public function deliver() + { + $this->checkAuth(); + $this->checkCartNotEmpty(); + + $message = false; + + $orderDelivery = new OrderDelivery($this->getRequest()); + + try { + $form = $this->validateForm($orderDelivery, "post"); + + $deliveryAddressId = $form->get("delivery-address")->getData(); + $deliveryModuleId = $form->get("delivery-module")->getData(); + $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); + $deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId); + + /* check that the delivery address belongs to the current customer */ + $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); + if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + throw new \Exception("Delivery address does not belong to the current customer"); + } + + /* check that the delivery module fetches the delivery address area */ + if(AreaDeliveryModuleQuery::create() + ->filterByAreaId($deliveryAddress->getCountry()->getAreaId()) + ->filterByDeliveryModuleId($deliveryModuleId) + ->count() == 0) { + throw new \Exception("Delivery module cannot be use with selected delivery address"); + } + + /* get postage amount */ + $moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace()); + $moduleInstance = $moduleReflection->newInstance(); + $postage = $moduleInstance->getPostage($deliveryAddress->getCountry()); + + $orderEvent = $this->getOrderEvent(); + $orderEvent->setDeliveryAddress($deliveryAddressId); + $orderEvent->setDeliveryModule($deliveryModuleId); + $orderEvent->setPostage($postage); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent); + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent); + + $this->redirectToRoute("order.invoice"); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (PropelException $e) { + $this->getParserContext()->setGeneralError($e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())); + + $orderDelivery->setErrorMessage($message); + + $this->getParserContext() + ->addForm($orderDelivery) + ->setGeneralError($message) + ; + } + + } + + /** + * set invoice address + * set payment module + */ + public function invoice() + { + $this->checkAuth(); + $this->checkCartNotEmpty(); + $this->checkValidDelivery(); + + $message = false; + + $orderPayment = new OrderPayment($this->getRequest()); + + try { + $form = $this->validateForm($orderPayment, "post"); + + $invoiceAddressId = $form->get("invoice-address")->getData(); + $paymentModuleId = $form->get("payment-module")->getData(); + + /* check that the invoice address belongs to the current customer */ + $invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId); + if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + throw new \Exception("Invoice address does not belong to the current customer"); + } + + $orderEvent = $this->getOrderEvent(); + $orderEvent->setInvoiceAddress($invoiceAddressId); + $orderEvent->setPaymentModule($paymentModuleId); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_INVOICE_ADDRESS, $orderEvent); + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_PAYMENT_MODULE, $orderEvent); + + $this->redirectToRoute("order.payment.process"); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (PropelException $e) { + $this->getParserContext()->setGeneralError($e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during order payment process : %s. Exception was %s", $message, $e->getMessage())); + + $orderPayment->setErrorMessage($message); + + $this->getParserContext() + ->addForm($orderPayment) + ->setGeneralError($message) + ; + } + + } + + public function pay() + { + /* check customer */ + $this->checkAuth(); + + /* check cart count */ + $this->checkCartNotEmpty(); + + /* check delivery address and module */ + $this->checkValidDelivery(); + + /* check invoice address and payment module */ + $this->checkValidInvoice(); + + $orderEvent = $this->getOrderEvent(); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent); + + $placedOrder = $orderEvent->getPlacedOrder(); + + if(null !== $placedOrder && null !== $placedOrder->getId()) { + /* order has been placed */ + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId())))); + } else { + /* order has not been placed */ + $this->redirectToRoute("cart.view"); + } + } + + public function orderPlaced($order_id) + { + /* check if the placed order matched the customer */ + $placedOrder = OrderQuery::create()->findPk( + $this->getRequest()->attributes->get('order_id') + ); + + if(null === $placedOrder) { + throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder); + } + + $customer = $this->getSecurityContext()->getCustomerUser(); + + if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) { + throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder); + } + + $this->getParserContext()->set("placed_order_id", $placedOrder->getId()); + } + + protected function getOrderEvent() + { + $order = $this->getOrder($this->getRequest()); + + return new OrderEvent($order); + } + + public function getOrder(Request $request) + { + $session = $request->getSession(); + + if (null !== $order = $session->getOrder()) { + return $order; + } + + $order = new Order(); + + $session->setOrder($order); + + return $order; + } +} diff --git a/core/lib/Thelia/Core/Event/AccessoryEvent.php b/core/lib/Thelia/Core/Event/AccessoryEvent.php new file mode 100644 index 000000000..1e14e6fb7 --- /dev/null +++ b/core/lib/Thelia/Core/Event/AccessoryEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Accessory; +use Thelia\Core\Event\ActionEvent; + +class AccessoryEvent extends ActionEvent +{ + public $accessory = null; + + public function __construct(Accessory $accessory = null) + { + $this->accessory = $accessory; + } + + public function hasAccessory() + { + return ! is_null($this->accessory); + } + + public function getAccessory() + { + return $this->accessory; + } + + public function setAccessory(Accessory $accessory) + { + $this->accessory = $accessory; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/CachedFileEvent.php b/core/lib/Thelia/Core/Event/CachedFileEvent.php new file mode 100644 index 000000000..8f3a026d9 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CachedFileEvent.php @@ -0,0 +1,94 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class CachedFileEvent extends ActionEvent +{ + /** + * @var string The complete file name (with path) of the source file + */ + protected $source_filepath = null; + /** + * @var string The target subdirectory in the cache + */ + protected $cache_subdirectory = null; + + /** + * @var string The absolute URL of the cached file (in the web space) + */ + protected $file_url = null; + + /** + * @var string The absolute path of the cached file + */ + protected $cache_filepath = null; + + public function getFileUrl() + { + return $this->file_url; + } + + public function setFileUrl($file_url) + { + $this->file_url = $file_url; + + return $this; + } + + public function getCacheFilepath() + { + return $this->cache_filepath; + } + + public function setCacheFilepath($cache_filepath) + { + $this->cache_filepath = $cache_filepath; + + return $this; + } + + public function getSourceFilepath() + { + return $this->source_filepath; + } + + public function setSourceFilepath($source_filepath) + { + $this->source_filepath = $source_filepath; + + return $this; + } + + public function getCacheSubdirectory() + { + return $this->cache_subdirectory; + } + + public function setCacheSubdirectory($cache_subdirectory) + { + $this->cache_subdirectory = $cache_subdirectory; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php b/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php new file mode 100644 index 000000000..3ca5b2ae5 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryAddContentEvent extends CategoryEvent +{ + protected $content_id; + + public function __construct(Category $category, $content_id) + { + parent::__construct($category); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryAssociatedContentEvent.php b/core/lib/Thelia/Core/Event/CategoryAssociatedContentEvent.php new file mode 100644 index 000000000..1984a042c --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryAssociatedContentEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Core\Event\ActionEvent; + +class CategoryAssociatedContentEvent extends ActionEvent +{ + public $content = null; + + public function __construct(CategoryAssociatedContent $content = null) + { + $this->content = $content; + } + + public function hasCategoryAssociatedContent() + { + return ! is_null($this->content); + } + + public function getCategoryAssociatedContent() + { + return $this->content; + } + + public function setCategoryAssociatedContent(CategoryAssociatedContent $content) + { + $this->content = $content; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 5a687217c..41529019c 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -28,13 +28,7 @@ class CategoryCreateEvent extends CategoryEvent protected $title; protected $parent; protected $locale; - - public function __construct($title, $parent, $locale) - { - $this->title = $title; - $this->parent = $parent; - $this->locale = $locale; - } + protected $visible; public function getTitle() { @@ -71,4 +65,16 @@ class CategoryCreateEvent extends CategoryEvent return $this; } + + public function getVisible() + { + return $this->visible; + } + + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } } diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php new file mode 100644 index 000000000..bb28beb21 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryDeleteContentEvent extends CategoryEvent +{ + protected $content_id; + + public function __construct(Category $category, $content_id) + { + parent::__construct($category); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php new file mode 100644 index 000000000..f90378e38 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class CategoryToggleVisibilityEvent extends CategoryEvent +{ +} diff --git a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php index 44e760549..f5f775a22 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php @@ -32,7 +32,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent protected $postscriptum; protected $url; - protected $visibility; protected $parent; public function __construct($category_id) @@ -100,18 +99,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent return $this; } - public function getVisibility() - { - return $this->visibility; - } - - public function setVisibility($visibility) - { - $this->visibility = $visibility; - - return $this; - } - public function getParent() { return $this->parent; diff --git a/core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php b/core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php new file mode 100644 index 000000000..5e2e7f0ea --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php @@ -0,0 +1,124 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; + + +/** + * Class ContentCreateEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentCreateEvent extends ContentEvent +{ + protected $title; + protected $default_folder; + protected $locale; + protected $visible; + + /** + * @param mixed $locale + * + * @return $this + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * @return mixed + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param mixed $default_folder + * + * @return $this + */ + public function setDefaultFolder($default_folder) + { + $this->default_folder = $default_folder; + + return $this; + } + + /** + * @return mixed + */ + public function getDefaultFolder() + { + return $this->default_folder; + } + + + + + /** + * @param mixed $visible + * + * @return $this + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * @return mixed + */ + public function getVisible() + { + return $this->visible; + } + + /** + * @param mixed $title + * + * @return $this + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Content/ContentEvent.php b/core/lib/Thelia/Core/Event/Content/ContentEvent.php new file mode 100644 index 000000000..0949348e3 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentEvent.php @@ -0,0 +1,73 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Content; + + +/** + * Class ContentEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentEvent extends ActionEvent +{ + /** + * @var \Thelia\Model\Content + */ + protected $content; + + function __construct(Content $content = null) + { + $this->content = $content; + } + + /** + * @param \Thelia\Model\Content $content + */ + public function setContent(Content $content) + { + $this->content = $content; + + return $this; + } + + /** + * @return \Thelia\Model\Content + */ + public function getContent() + { + return $this->content; + } + + /** + * check if content exists + * + * @return bool + */ + public function hasContent() + { + return null !== $this->content; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php b/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php new file mode 100644 index 000000000..f7c75a01f --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php @@ -0,0 +1,150 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; + + +/** + * Class ContentUpdateEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentUpdateEvent extends ContentCreateEvent +{ + protected $content_id; + + protected $chapo; + protected $description; + protected $postscriptum; + + protected $url; + + function __construct($content_id) + { + $this->content_id = $content_id; + } + + /** + * @param mixed $chapo + * + * @return $this + */ + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + /** + * @return mixed + */ + public function getChapo() + { + return $this->chapo; + } + + /** + * @param mixed $content_id + * + * @return $this + */ + public function setContentId($content_id) + { + $this->content_id = $content_id; + + return $this; + } + + /** + * @return mixed + */ + public function getContentId() + { + return $this->content_id; + } + + /** + * @param mixed $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param mixed $postscriptum + * + * @return $this + */ + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + /** + * @return mixed + */ + public function getPostscriptum() + { + return $this->postscriptum; + } + + /** + * @param mixed $url + * + * @return $this + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php similarity index 54% rename from core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php rename to core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php index db8e14243..df5cef7a9 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php @@ -22,6 +22,8 @@ /**********************************************************************************/ namespace Thelia\Core\Event\Coupon; +use Thelia\Core\Event\ActionEvent; +use Thelia\Coupon\CouponRuleCollection; use Thelia\Model\Coupon; /** @@ -29,75 +31,112 @@ use Thelia\Model\Coupon; * Date: 8/29/13 * Time: 3:45 PM * - * Occurring when a Coupon is disabled + * Occurring when a Coupon is consumed * * @package Coupon * @author Guillaume MOREL * */ -class CouponDisableEvent extends ActionEvent +class CouponConsumeEvent extends ActionEvent { - /** @var int Coupon id */ - protected $couponId; + /** @var string Coupon code */ + protected $code = null; - /** @var Coupon Coupon being disabled */ - protected $disabledCoupon; + /** @var float Total discount given by this coupon */ + protected $discount = 0; + + /** @var bool If Coupon is valid or if Customer meets coupon conditions */ + protected $isValid = null; /** * Constructor * - * @param int $id Coupon Id + * @param string $code Coupon code + * @param float $discount Total discount given by this coupon + * @param bool $isValid If Coupon is valid or + * if Customer meets coupon conditions */ - public function __construct($id) + function __construct($code, $discount = null, $isValid = null) { - $this->id = $id; + $this->code = $code; + $this->discount = $discount; + $this->isValid = $isValid; } /** - * Get Coupon id + * Set Coupon code * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Set Coupon id - * - * @param int $id Coupon id + * @param string $code Coupon code * * @return $this */ - public function setId($id) + public function setCode($code) { - $this->id = $id; + $this->code = $code; return $this; } /** - * Get Coupon being disabled + * Get Coupon code * - * @return Coupon + * @return string */ - public function getDisabledCoupon() + public function getCode() { - return $this->disabledCoupon; + return $this->code; } /** - * Set Coupon to be disabled + * Set total discount given by this coupon * - * @param Coupon $disabledCoupon Coupon to disable + * @param float $discount Total discount given by this coupon * * @return $this */ - public function setDisabledCoupon(Coupon $disabledCoupon) + public function setDiscount($discount) { - $this->disabledCoupon = $disabledCoupon; + $this->discount = $discount; return $this; } + + /** + * Get total discount given by this coupon + * + * @return float + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * Set if Coupon is valid or if Customer meets coupon conditions + * + * @param boolean $isValid if Coupon is valid or + * if Customer meets coupon conditions + * + * @return $this + */ + public function setIsValid($isValid) + { + $this->isValid = $isValid; + + return $this; + } + + /** + * Get if Coupon is valid or if Customer meets coupon conditions + * + * @return boolean + */ + public function getIsValid() + { + return $this->isValid; + } + + + + } diff --git a/core/lib/Thelia/Core/Event/DocumentEvent.php b/core/lib/Thelia/Core/Event/DocumentEvent.php new file mode 100644 index 000000000..f58d51083 --- /dev/null +++ b/core/lib/Thelia/Core/Event/DocumentEvent.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class DocumentEvent extends CachedFileEvent +{ + protected $document_path; + protected $document_url; + + /** + * @return the document file path + */ + public function getDocumentPath() + { + return $this->document_path; + } + + /** + * @param string $document_path the document file path + */ + public function setDocumentPath($document_path) + { + $this->document_path = $document_path; + + return $this; + } + + /** + * @return the document URL + */ + public function getDocumentUrl() + { + return $this->document_url; + } + + /** + * @param string $document_url the document URL + */ + public function setDocumentUrl($document_url) + { + $this->document_url = $document_url; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php b/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php new file mode 100644 index 000000000..2c8fb228e --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php @@ -0,0 +1,68 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureAvCreateEvent extends FeatureAvEvent +{ + protected $title; + protected $locale; + protected $feature_id; + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php b/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php new file mode 100644 index 000000000..aa0a3c729 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureAvDeleteEvent extends FeatureAvEvent +{ + protected $featureAv_id; + + public function __construct($featureAv_id) + { + $this->setFeatureAvId($featureAv_id); + } + + public function getFeatureAvId() + { + return $this->featureAv_id; + } + + public function setFeatureAvId($featureAv_id) + { + $this->featureAv_id = $featureAv_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvEvent.php b/core/lib/Thelia/Core/Event/FeatureAvEvent.php new file mode 100644 index 000000000..225acaf11 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; +use Thelia\Model\FeatureAv; + +class FeatureAvEvent extends ActionEvent +{ + protected $featureAv = null; + + public function __construct(FeatureAv $featureAv = null) + { + $this->featureAv = $featureAv; + } + + public function hasFeatureAv() + { + return ! is_null($this->featureAv); + } + + public function getFeatureAv() + { + return $this->featureAv; + } + + public function setFeatureAv($featureAv) + { + $this->featureAv = $featureAv; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php b/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php new file mode 100644 index 000000000..5db9604c2 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php @@ -0,0 +1,86 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureAvUpdateEvent extends FeatureAvCreateEvent +{ + protected $featureAv_id; + + protected $description; + protected $chapo; + protected $postscriptum; + + public function __construct($featureAv_id) + { + $this->setFeatureAvId($featureAv_id); + } + + public function getFeatureAvId() + { + return $this->featureAv_id; + } + + public function setFeatureAvId($featureAv_id) + { + $this->featureAv_id = $featureAv_id; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureCreateEvent.php b/core/lib/Thelia/Core/Event/FeatureCreateEvent.php new file mode 100644 index 000000000..574433084 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureCreateEvent.php @@ -0,0 +1,68 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureCreateEvent extends FeatureEvent +{ + protected $title; + protected $locale; + protected $add_to_all_templates; + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + public function getAddToAllTemplates() + { + return $this->add_to_all_templates; + } + + public function setAddToAllTemplates($add_to_all_templates) + { + $this->add_to_all_templates = $add_to_all_templates; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php b/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php new file mode 100644 index 000000000..1eca57982 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureDeleteEvent extends FeatureEvent +{ + protected $feature_id; + + public function __construct($feature_id) + { + $this->setFeatureId($feature_id); + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureEvent.php b/core/lib/Thelia/Core/Event/FeatureEvent.php new file mode 100644 index 000000000..f1510ac63 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; +use Thelia\Model\Feature; + +class FeatureEvent extends ActionEvent +{ + protected $feature = null; + + public function __construct(Feature $feature = null) + { + $this->feature = $feature; + } + + public function hasFeature() + { + return ! is_null($this->feature); + } + + public function getFeature() + { + return $this->feature; + } + + public function setFeature($feature) + { + $this->feature = $feature; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php b/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php new file mode 100644 index 000000000..6bee33ebb --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php @@ -0,0 +1,86 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureUpdateEvent extends FeatureCreateEvent +{ + protected $feature_id; + + protected $description; + protected $chapo; + protected $postscriptum; + + public function __construct($feature_id) + { + $this->setFeatureId($feature_id); + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FolderCreateEvent.php b/core/lib/Thelia/Core/Event/FolderCreateEvent.php new file mode 100644 index 000000000..609fea6f8 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FolderCreateEvent.php @@ -0,0 +1,120 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class FolderCreateEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderCreateEvent extends FolderEvent { + protected $title; + protected $parent; + protected $locale; + protected $visible; + + /** + * @param mixed $locale + * + * @return $this + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * @return mixed + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param mixed $parent + * + * + * @return $this + */ + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } + + /** + * @return mixed + */ + public function getParent() + { + return $this->parent; + } + + /** + * @param mixed $title + * + * @return $this + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param mixed $visible + * + * @return $this + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * @return mixed + */ + public function getVisible() + { + return $this->visible; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Install/BaseInstallController.php b/core/lib/Thelia/Core/Event/FolderDeleteEvent.php similarity index 71% rename from core/lib/Thelia/Controller/Install/BaseInstallController.php rename to core/lib/Thelia/Core/Event/FolderDeleteEvent.php index 35293904e..1ef83ef51 100644 --- a/core/lib/Thelia/Controller/Install/BaseInstallController.php +++ b/core/lib/Thelia/Core/Event/FolderDeleteEvent.php @@ -21,39 +21,44 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Install; -use Symfony\Component\HttpFoundation\Response; -use Thelia\Controller\BaseController; +namespace Thelia\Core\Event; + /** - * Class BaseInstallController - * @package Thelia\Controller\Install + * Class FolderDeleteEvent + * @package Thelia\Core\Event * @author Manuel Raynaud */ -class BaseInstallController extends BaseController -{ +class FolderDeleteEvent extends FolderEvent{ + /** - * @return a ParserInterface instance parser + * @var int folder id */ - protected function getParser() + protected $folder_id; + + /** + * @param int $folder_id + */ + function __construct($folder_id) { - $parser = $this->container->get("thelia.parser"); - - // Define the template thant shoud be used - $parser->setTemplate("install"); - - return $parser; + $this->folder_id = $folder_id; } - public function render($templateName, $args = array()) + /** + * @param int $folder_id + */ + public function setFolderId($folder_id) { - return new Response($this->renderRaw($templateName, $args)); + $this->folder_id = $folder_id; } - public function renderRaw($templateName, $args = array()) + /** + * @return int + */ + public function getFolderId() { - $data = $this->getParser()->render($templateName, $args); - - return $data; + return $this->folder_id; } -} + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Install/InstallController.php b/core/lib/Thelia/Core/Event/FolderEvent.php similarity index 69% rename from core/lib/Thelia/Controller/Install/InstallController.php rename to core/lib/Thelia/Core/Event/FolderEvent.php index 0514ba0ff..8ae8223b5 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Core/Event/FolderEvent.php @@ -21,48 +21,53 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Install; -use Thelia\Install\CheckPermission; +namespace Thelia\Core\Event; +use Thelia\Model\Folder; + /** - * Class InstallController - * @package Thelia\Controller\Install + * Class FolderEvent + * @package Thelia\Core\Event * @author Manuel Raynaud */ -class InstallController extends BaseInstallController -{ - public function index() +class FolderEvent extends ActionEvent { + + /** + * @var \Thelia\Model\Folder + */ + protected $folder; + + function __construct(Folder $folder = null) { - $this->verifyStep(1); - - $this->getSession()->set("step", 1); - - $this->render("index.html"); + $this->folder = $folder; } - public function checkPermission() + /** + * @param \Thelia\Model\Folder $folder + */ + public function setFolder(Folder $folder) { - $this->verifyStep(2); + $this->folder = $folder; - $permission = new CheckPermission(); + return $this; } - protected function verifyStep($step) + /** + * @return \Thelia\Model\Folder + */ + public function getFolder() { - $session = $this->getSession(); - - if ($session->has("step")) { - $sessionStep = $session->get("step"); - } else { - return true; - } - - switch ($step) { - case "1" : - if ($sessionStep > 1) { - $this->redirect("/install/step/2"); - } - break; - } + return $this->folder; } -} + + /** + * test if a folder object exists + * + * @return bool + */ + public function hasFolder() + { + return null !== $this->folder; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php new file mode 100644 index 000000000..9d7c53ab7 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php @@ -0,0 +1,34 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class FolderToggleVisibilityEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderToggleVisibilityEvent extends FolderEvent { + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/FolderUpdateEvent.php b/core/lib/Thelia/Core/Event/FolderUpdateEvent.php new file mode 100644 index 000000000..47c3b28cf --- /dev/null +++ b/core/lib/Thelia/Core/Event/FolderUpdateEvent.php @@ -0,0 +1,136 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class FolderUpdateEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderUpdateEvent extends FolderCreateEvent { + protected $folder_id; + + protected $chapo; + protected $description; + protected $postscriptum; + + protected $url; + + function __construct($folder_id) + { + $this->folder_id = $folder_id; + } + + /** + * @param mixed $chapo + */ + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + /** + * @return mixed + */ + public function getChapo() + { + return $this->chapo; + } + + /** + * @param mixed $description + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param mixed $folder_id + */ + public function setFolderId($folder_id) + { + $this->folder_id = $folder_id; + + return $this; + } + + /** + * @return mixed + */ + public function getFolderId() + { + return $this->folder_id; + } + + /** + * @param mixed $postscriptum + */ + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + /** + * @return mixed + */ + public function getPostscriptum() + { + return $this->postscriptum; + } + + /** + * @param mixed $url + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php b/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php new file mode 100644 index 000000000..7ee22cddd --- /dev/null +++ b/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class GenerateRewrittenUrlEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class GenerateRewrittenUrlEvent extends ActionEvent { + + protected $object; + protected $locale; + + protected $url; + + public function __construct($object, $locale) + { + $this->object; + $this->locale; + } + + public function setUrl($url) + { + $this->url = $url; + } + + public function isRewritten() + { + return null !== $this->url; + } + + public function getUrl() + { + return $this->url; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/ImageEvent.php b/core/lib/Thelia/Core/Event/ImageEvent.php index 5ea1581cd..462fa012d 100755 --- a/core/lib/Thelia/Core/Event/ImageEvent.php +++ b/core/lib/Thelia/Core/Event/ImageEvent.php @@ -23,22 +23,8 @@ namespace Thelia\Core\Event; -class ImageEvent extends ActionEvent +class ImageEvent extends CachedFileEvent { - /** - * @var string The complete file name (with path) of the source image - */ - protected $source_filepath = null; - /** - * @var string The target subdirectory in the image cache - */ - protected $cache_subdirectory = null; - - /** - * @var string The absolute URL of the cached image (in the web space) - */ - protected $file_url = null; - /** * @var string The absolute path of the cached image file */ @@ -121,6 +107,8 @@ class ImageEvent extends ActionEvent public function setCategory($category) { $this->category = $category; + + return $this; } public function getWidth() @@ -131,6 +119,8 @@ class ImageEvent extends ActionEvent public function setWidth($width) { $this->width = $width; + + return $this; } public function getHeight() @@ -141,6 +131,8 @@ class ImageEvent extends ActionEvent public function setHeight($height) { $this->height = $height; + + return $this; } public function getResizeMode() @@ -151,6 +143,8 @@ class ImageEvent extends ActionEvent public function setResizeMode($resize_mode) { $this->resize_mode = $resize_mode; + + return $this; } public function getBackgroundColor() @@ -161,6 +155,8 @@ class ImageEvent extends ActionEvent public function setBackgroundColor($background_color) { $this->background_color = $background_color; + + return $this; } public function getEffects() @@ -171,6 +167,8 @@ class ImageEvent extends ActionEvent public function setEffects(array $effects) { $this->effects = $effects; + + return $this; } public function getRotation() @@ -181,46 +179,8 @@ class ImageEvent extends ActionEvent public function setRotation($rotation) { $this->rotation = $rotation; - } - public function getFileUrl() - { - return $this->file_url; - } - - public function setFileUrl($file_url) - { - $this->file_url = $file_url; - } - - public function getCacheFilepath() - { - return $this->cache_filepath; - } - - public function setCacheFilepath($cache_filepath) - { - $this->cache_filepath = $cache_filepath; - } - - public function getSourceFilepath() - { - return $this->source_filepath; - } - - public function setSourceFilepath($source_filepath) - { - $this->source_filepath = $source_filepath; - } - - public function getCacheSubdirectory() - { - return $this->cache_subdirectory; - } - - public function setCacheSubdirectory($cache_subdirectory) - { - $this->cache_subdirectory = $cache_subdirectory; + return $this; } public function getQuality() @@ -231,6 +191,8 @@ class ImageEvent extends ActionEvent public function setQuality($quality) { $this->quality = $quality; + + return $this; } public function getOriginalFileUrl() @@ -241,6 +203,8 @@ class ImageEvent extends ActionEvent public function setOriginalFileUrl($original_file_url) { $this->original_file_url = $original_file_url; + + return $this; } public function getCacheOriginalFilepath() @@ -251,5 +215,7 @@ class ImageEvent extends ActionEvent public function setCacheOriginalFilepath($cache_original_filepath) { $this->cache_original_filepath = $cache_original_filepath; + + return $this; } } diff --git a/core/lib/Thelia/Core/Event/MailTransporterEvent.php b/core/lib/Thelia/Core/Event/MailTransporterEvent.php new file mode 100644 index 000000000..d47ac693f --- /dev/null +++ b/core/lib/Thelia/Core/Event/MailTransporterEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class MailTransporterEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class MailTransporterEvent extends ActionEvent { + /** + * @var \Swift_Transport + */ + protected $transporter; + + public function setMailerTransporter(\Swift_Transport $transporter) + { + $this->transporter = $transporter; + } + + public function getTransporter() + { + return $this->transporter; + } + + public function hasTransporter() + { + return null !== $this->transporter; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php new file mode 100755 index 000000000..7089141bb --- /dev/null +++ b/core/lib/Thelia/Core/Event/OrderEvent.php @@ -0,0 +1,174 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Order; + +class OrderEvent extends ActionEvent +{ + protected $order = null; + protected $placedOrder = null; + protected $invoiceAddress = null; + protected $deliveryAddress = null; + protected $deliveryModule = null; + protected $paymentModule = null; + protected $postage = null; + protected $ref = null; + + /** + * @param Order $order + */ + public function __construct(Order $order) + { + $this->setOrder($order); + } + + /** + * @param Order $order + */ + public function setOrder(Order $order) + { + $this->order = $order; + } + + /** + * @param Order $order + */ + public function setPlacedOrder(Order $order) + { + $this->placedOrder = $order; + } + + /** + * @param $address + */ + public function setInvoiceAddress($address) + { + $this->invoiceAddress = $address; + } + + /** + * @param $address + */ + public function setDeliveryAddress($address) + { + $this->deliveryAddress = $address; + } + + /** + * @param $module + */ + public function setDeliveryModule($module) + { + $this->deliveryModule = $module; + } + + /** + * @param $module + */ + public function setPaymentModule($module) + { + $this->paymentModule = $module; + } + + /** + * @param $postage + */ + public function setPostage($postage) + { + $this->postage = $postage; + } + + /** + * @param $ref + */ + public function setRef($ref) + { + $this->ref = $ref; + } + + /** + * @return null|Order + */ + public function getOrder() + { + return $this->order; + } + + /** + * @return null|Order + */ + public function getPlacedOrder() + { + return $this->placedOrder; + } + + /** + * @return null|int + */ + public function getInvoiceAddress() + { + return $this->invoiceAddress; + } + + /** + * @return null|int + */ + public function getDeliveryAddress() + { + return $this->deliveryAddress; + } + + /** + * @return null|int + */ + public function getDeliveryModule() + { + return $this->deliveryModule; + } + + /** + * @return null|int + */ + public function getPaymentModule() + { + return $this->paymentModule; + } + + /** + * @return null|int + */ + public function getPostage() + { + return $this->postage; + } + + /** + * @return null|int + */ + public function getRef() + { + return $this->ref; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php b/core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php new file mode 100644 index 000000000..d3f2ba19b --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductAddAccessoryEvent extends ProductEvent +{ + protected $accessory_id; + + public function __construct(Product $product, $accessory_id) + { + parent::__construct($product); + + $this->accessory_id = $accessory_id; + } + + public function getAccessoryId() + { + return $this->accessory_id; + } + + public function setAccessoryId($accessory_id) + { + $this->accessory_id = $accessory_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductAddContentEvent.php b/core/lib/Thelia/Core/Event/ProductAddContentEvent.php new file mode 100644 index 000000000..8cd648753 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductAddContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductAddContentEvent extends ProductEvent +{ + protected $content_id; + + public function __construct(Product $product, $content_id) + { + parent::__construct($product); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php b/core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php new file mode 100644 index 000000000..ba41b5ede --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\ProductAssociatedContent; +use Thelia\Core\Event\ActionEvent; + +class ProductAssociatedContentEvent extends ActionEvent +{ + public $content = null; + + public function __construct(ProductAssociatedContent $content = null) + { + $this->content = $content; + } + + public function hasProductAssociatedContent() + { + return ! is_null($this->content); + } + + public function getProductAssociatedContent() + { + return $this->content; + } + + public function setProductAssociatedContent(ProductAssociatedContent $content) + { + $this->content = $content; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductCreateEvent.php b/core/lib/Thelia/Core/Event/ProductCreateEvent.php new file mode 100644 index 000000000..d2d30a11a --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductCreateEvent.php @@ -0,0 +1,88 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductCreateEvent extends ProductEvent +{ + protected $ref; + protected $title; + protected $locale; + protected $default_category; + protected $visible; + + public function getRef() + { + return $this->ref; + } + + public function setRef($ref) + { + $this->ref = $ref; + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + public function getDefaultCategory() + { + return $this->default_category; + } + + public function setDefaultCategory($default_category) + { + $this->default_category = $default_category; + return $this; + } + + public function getVisible() + { + return $this->visible; + } + + public function setVisible($visible) + { + $this->visible = $visible; + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php b/core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php new file mode 100644 index 000000000..9644cdacc --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductDeleteAccessoryEvent extends ProductEvent +{ + protected $accessory_id; + + public function __construct(Product $product, $accessory_id) + { + parent::__construct($product); + + $this->accessory_id = $accessory_id; + } + + public function getAccessoryId() + { + return $this->accessory_id; + } + + public function setAccessoryId($accessory_id) + { + $this->accessory_id = $accessory_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php b/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php new file mode 100644 index 000000000..f3cdbda1f --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductDeleteContentEvent extends ProductEvent +{ + protected $content_id; + + public function __construct(Product $product, $content_id) + { + parent::__construct($product); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductDeleteEvent.php b/core/lib/Thelia/Core/Event/ProductDeleteEvent.php new file mode 100644 index 000000000..43273887c --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductDeleteEvent.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductDeleteEvent extends ProductEvent +{ + public function __construct($product_id) + { + $this->product_id = $product_id; + } + + public function getProductId() + { + return $this->product_id; + } + + public function setProductId($product_id) + { + $this->product_id = $product_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductEvent.php b/core/lib/Thelia/Core/Event/ProductEvent.php new file mode 100644 index 000000000..6decd8101 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; +use Thelia\Core\Event\ActionEvent; + +class ProductEvent extends ActionEvent +{ + public $product = null; + + public function __construct(Product $product = null) + { + $this->product = $product; + } + + public function hasProduct() + { + return ! is_null($this->product); + } + + public function getProduct() + { + return $this->product; + } + + public function setProduct(Product $product) + { + $this->product = $product; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php new file mode 100644 index 000000000..732cfac76 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductToggleVisibilityEvent extends ProductEvent +{ +} diff --git a/core/lib/Thelia/Core/Event/ProductUpdateEvent.php b/core/lib/Thelia/Core/Event/ProductUpdateEvent.php new file mode 100644 index 000000000..8ade33c74 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductUpdateEvent.php @@ -0,0 +1,113 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductUpdateEvent extends ProductCreateEvent +{ + protected $product_id; + + protected $chapo; + protected $description; + protected $postscriptum; + + protected $url; + protected $parent; + + public function __construct($product_id) + { + $this->product_id = $product_id; + } + + public function getProductId() + { + return $this->product_id; + } + + public function setProductId($product_id) + { + $this->product_id = $product_id; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + public function getUrl() + { + return $this->url; + } + + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php b/core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php new file mode 100644 index 000000000..6adebf080 --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Template; +class TemplateAddAttributeEvent extends TemplateEvent +{ + protected $attribute_id; + + public function __construct(Template $template, $attribute_id) + { + + parent::__construct($template); + + $this->attribute_id = $attribute_id; + } + + public function getAttributeId() + { + return $this->attribute_id; + } + + public function setAttributeId($attribute_id) + { + $this->attribute_id = $attribute_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php b/core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php new file mode 100644 index 000000000..ccfecb95a --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Template; +class TemplateAddFeatureEvent extends TemplateEvent +{ + protected $feature_id; + + public function __construct(Template $template, $feature_id) + { + + parent::__construct($template); + + $this->feature_id = $feature_id; + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/TemplateCreateEvent.php b/core/lib/Thelia/Core/Event/TemplateCreateEvent.php new file mode 100644 index 000000000..b966ce09b --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateCreateEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class TemplateCreateEvent extends TemplateEvent +{ + protected $template_name; + protected $locale; + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getTemplateName() + { + return $this->template_name; + } + + public function setTemplateName($template_name) + { + $this->template_name = $template_name; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php b/core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php new file mode 100644 index 000000000..3df83422d --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Template; + +class TemplateDeleteAttributeEvent extends TemplateEvent +{ + protected $attribute_id; + + public function __construct(Template $template, $attribute_id) + { + + parent::__construct($template); + + $this->attribute_id = $attribute_id; + } + + public function getAttributeId() + { + return $this->attribute_id; + } + + public function setAttributeId($attribute_id) + { + $this->attribute_id = $attribute_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TemplateDeleteEvent.php b/core/lib/Thelia/Core/Event/TemplateDeleteEvent.php new file mode 100644 index 000000000..de504cc98 --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateDeleteEvent.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class TemplateDeleteEvent extends TemplateEvent +{ + protected $template_id; + protected $product_count; + + public function __construct($template_id) + { + $this->setTemplateId($template_id); + } + + public function getTemplateId() + { + return $this->template_id; + } + + public function setTemplateId($template_id) + { + $this->template_id = $template_id; + + return $this; + } + + public function getProductCount() + { + return $this->product_count; + } + + public function setProductCount($product_count) + { + $this->product_count = $product_count; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php b/core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php new file mode 100644 index 000000000..83f73d923 --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Template; + +class TemplateDeleteFeatureEvent extends TemplateEvent +{ + protected $feature_id; + + public function __construct(Template $template, $feature_id) + { + + parent::__construct($template); + + $this->feature_id = $feature_id; + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TemplateEvent.php b/core/lib/Thelia/Core/Event/TemplateEvent.php new file mode 100644 index 000000000..96945189e --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; +use Thelia\Model\Template; + +class TemplateEvent extends ActionEvent +{ + protected $template = null; + + public function __construct(Template $template = null) + { + $this->template = $template; + } + + public function hasTemplate() + { + return ! is_null($this->template); + } + + public function getTemplate() + { + return $this->template; + } + + public function setTemplate($template) + { + $this->template = $template; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TemplateUpdateEvent.php b/core/lib/Thelia/Core/Event/TemplateUpdateEvent.php new file mode 100644 index 000000000..bae8ec7da --- /dev/null +++ b/core/lib/Thelia/Core/Event/TemplateUpdateEvent.php @@ -0,0 +1,71 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class TemplateUpdateEvent extends TemplateCreateEvent +{ + protected $template_id; + + protected $feature_list; + protected $attribute_list; + + public function __construct($template_id) + { + $this->setTemplateId($template_id); + } + + public function getTemplateId() + { + return $this->template_id; + } + + public function setTemplateId($template_id) + { + $this->template_id = $template_id; + + return $this; + } + + public function getFeatureList() + { + return $this->feature_list; + } + + public function setFeatureList($feature_list) + { + $this->feature_list = $feature_list; + return $this; + } + + public function getAttributeList() + { + return $this->attribute_list; + } + + public function setAttributeList($attribute_list) + { + $this->attribute_list = $attribute_list; + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 54f05c0c0..ee49d239b 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -145,52 +145,123 @@ final class TheliaEvents // -- END ADDRESS MANAGEMENT --------------------------------------------------------- - /** - * Sent once the category creation form has been successfully validated, and before category insertion in the database. - */ - const BEFORE_CREATECATEGORY = "action.before_createcategory"; + // -- Categories management ----------------------------------------------- - /** - * Create, change or delete a category - */ - const CATEGORY_CREATE = "action.createCategory"; - const CATEGORY_UPDATE = "action.updateCategory"; - const CATEGORY_DELETE = "action.deleteCategory"; - - /** - * Toggle category visibility - */ + const CATEGORY_CREATE = "action.createCategory"; + const CATEGORY_UPDATE = "action.updateCategory"; + const CATEGORY_DELETE = "action.deleteCategory"; const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; + const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; - /** - * Change category position - */ - const CATEGORY_CHANGE_POSITION = "action.updateCategoryPosition"; + const CATEGORY_ADD_CONTENT = "action.categoryAddContent"; + const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent"; - /** - * Sent just after a successful insert of a new category in the database. - */ + const BEFORE_CREATECATEGORY = "action.before_createcategory"; const AFTER_CREATECATEGORY = "action.after_createcategory"; - /** - * Sent befonre deleting a category - */ - const BEFORE_DELETECATEGORY = "action.before_deletecategory"; - /** - * Sent just after a successful delete of a category from the database. - */ + const BEFORE_DELETECATEGORY = "action.before_deletecategory"; const AFTER_DELETECATEGORY = "action.after_deletecategory"; - /** - * Sent just before a successful change of a category in the database. - */ const BEFORE_UPDATECATEGORY = "action.before_updateCategory"; - - /** - * Sent just after a successful change of a category in the database. - */ const AFTER_UPDATECATEGORY = "action.after_updateCategory"; + // -- folder management ----------------------------------------------- + + const FOLDER_CREATE = "action.createFolder"; + const FOLDER_UPDATE = "action.updateFolder"; + const FOLDER_DELETE = "action.deleteFolder"; + const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility"; + const FOLDER_UPDATE_POSITION = "action.updateFolderPosition"; + +// const FOLDER_ADD_CONTENT = "action.categoryAddContent"; +// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent"; + + const BEFORE_CREATEFOLDER = "action.before_createFolder"; + const AFTER_CREATEFOLDER = "action.after_createFolder"; + + const BEFORE_DELETEFOLDER = "action.before_deleteFolder"; + const AFTER_DELETEFOLDER = "action.after_deleteFolder"; + + const BEFORE_UPDATEFOLDER = "action.before_updateFolder"; + const AFTER_UPDATEFOLDER = "action.after_updateFolder"; + + // -- content management ----------------------------------------------- + + const CONTENT_CREATE = "action.createContent"; + const CONTENT_UPDATE = "action.updateContent"; + const CONTENT_DELETE = "action.deleteContent"; + const CONTENT_TOGGLE_VISIBILITY = "action.toggleContentVisibility"; + const CONTENT_UPDATE_POSITION = "action.updateContentPosition"; + +// const FOLDER_ADD_CONTENT = "action.categoryAddContent"; +// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent"; + + const BEFORE_CREATECONTENT = "action.before_createContent"; + const AFTER_CREATECONTENT = "action.after_createContent"; + + const BEFORE_DELETECONTENT = "action.before_deleteContent"; + const AFTER_DELETECONTENT = "action.after_deleteContent"; + + const BEFORE_UPDATECONTENT = "action.before_updateContent"; + const AFTER_UPDATECONTENT = "action.after_updateContent"; + + // -- Categories Associated Content ---------------------------------------- + + const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent"; + const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent"; + + const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContenty"; + const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory"; + + const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent"; + const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent"; + + // -- Product management ----------------------------------------------- + + const PRODUCT_CREATE = "action.createProduct"; + const PRODUCT_UPDATE = "action.updateProduct"; + const PRODUCT_DELETE = "action.deleteProduct"; + const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility"; + const PRODUCT_UPDATE_POSITION = "action.updateProductPosition"; + + const PRODUCT_ADD_CONTENT = "action.productAddContent"; + const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; + + const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory"; + const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory"; + const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition"; + + const BEFORE_CREATEPRODUCT = "action.before_createproduct"; + const AFTER_CREATEPRODUCT = "action.after_createproduct"; + + const BEFORE_DELETEPRODUCT = "action.before_deleteproduct"; + const AFTER_DELETEPRODUCT = "action.after_deleteproduct"; + + const BEFORE_UPDATEPRODUCT = "action.before_updateProduct"; + const AFTER_UPDATEPRODUCT = "action.after_updateProduct"; + + // -- Product Accessories -------------------------------------------------- + + const BEFORE_CREATEACCESSORY = "action.before_createAccessory"; + const AFTER_CREATEACCESSORY = "action.after_createAccessory"; + + const BEFORE_DELETEACCESSORY = "action.before_deleteAccessory"; + const AFTER_DELETEACCESSORY = "action.after_deleteAccessory"; + + const BEFORE_UPDATEACCESSORY = "action.before_updateAccessory"; + const AFTER_UPDATEACCESSORY = "action.after_updateAccessory"; + + // -- Product Associated Content -------------------------------------------------- + + const BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.before_createProductAssociatedContent"; + const AFTER_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.after_createProductAssociatedContent"; + + const BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.before_deleteProductAssociatedContenty"; + const AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory"; + + const BEFORE_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.before_updateProductAssociatedContent"; + const AFTER_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.after_updateProductAssociatedContent"; + /** * sent when a new existing cat id duplicated. This append when current customer is different from current cart */ @@ -218,13 +289,33 @@ final class TheliaEvents const CART_DELETEITEM = "action.deleteArticle"; + /** + * Order linked event + */ + const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress"; + const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule"; + const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress"; + const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule"; + const ORDER_PAY = "action.order.pay"; + const ORDER_BEFORE_CREATE = "action.order.beforeCreate"; + const ORDER_AFTER_CREATE = "action.order.afterCreate"; + const ORDER_BEFORE_PAYMENT = "action.order.beforePayment"; + + const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate"; + const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate"; + /** * Sent on image processing */ const IMAGE_PROCESS = "action.processImage"; /** - * Sent on cimage cache clear request + * Sent on document processing + */ + const DOCUMENT_PROCESS = "action.processDocument"; + + /** + * Sent on image cache clear request */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; @@ -258,36 +349,6 @@ final class TheliaEvents */ const AFTER_UPDATE_COUPON = "action.after_update_coupon"; - /** - * Sent when disabling a Coupon - */ - const COUPON_DISABLE = "action.disable_coupon"; - - /** - * Sent just before a successful disable of a new Coupon in the database. - */ - const BEFORE_DISABLE_COUPON = "action.before_disable_coupon"; - - /** - * Sent just after a successful disable of a new Coupon in the database. - */ - const AFTER_DISABLE_COUPON = "action.after_disable_coupon"; - - /** - * Sent when enabling a Coupon - */ - const COUPON_ENABLE = "action.enable_coupon"; - - /** - * Sent just before a successful enable of a new Coupon in the database. - */ - const BEFORE_ENABLE_COUPON = "action.before_enable_coupon"; - - /** - * Sent just after a successful enable of a new Coupon in the database. - */ - const AFTER_ENABLE_COUPON = "action.after_enable_coupon"; - /** * Sent when attempting to use a Coupon */ @@ -367,6 +428,28 @@ final class TheliaEvents const BEFORE_DELETECURRENCY = "action.before_deleteCurrency"; const AFTER_DELETECURRENCY = "action.after_deleteCurrency"; + const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency'; + // -- Product templates management ----------------------------------------- + + const TEMPLATE_CREATE = "action.createTemplate"; + const TEMPLATE_UPDATE = "action.updateTemplate"; + const TEMPLATE_DELETE = "action.deleteTemplate"; + + const TEMPLATE_ADD_ATTRIBUTE = "action.templateAddAttribute"; + const TEMPLATE_DELETE_ATTRIBUTE = "action.templateDeleteAttribute"; + + const TEMPLATE_ADD_FEATURE = "action.templateAddFeature"; + const TEMPLATE_DELETE_FEATURE = "action.templateDeleteFeature"; + + const BEFORE_CREATETEMPLATE = "action.before_createTemplate"; + const AFTER_CREATETEMPLATE = "action.after_createTemplate"; + + const BEFORE_UPDATETEMPLATE = "action.before_updateTemplate"; + const AFTER_UPDATETEMPLATE = "action.after_updateTemplate"; + + const BEFORE_DELETETEMPLATE = "action.before_deleteTemplate"; + const AFTER_DELETETEMPLATE = "action.after_deleteTemplate"; + // -- Attributes management --------------------------------------------- const ATTRIBUTE_CREATE = "action.createAttribute"; @@ -386,6 +469,25 @@ final class TheliaEvents const BEFORE_DELETEATTRIBUTE = "action.before_deleteAttribute"; const AFTER_DELETEATTRIBUTE = "action.after_deleteAttribute"; + // -- Features management --------------------------------------------- + + const FEATURE_CREATE = "action.createFeature"; + const FEATURE_UPDATE = "action.updateFeature"; + const FEATURE_DELETE = "action.deleteFeature"; + const FEATURE_UPDATE_POSITION = "action.updateFeaturePosition"; + + const FEATURE_REMOVE_FROM_ALL_TEMPLATES = "action.addFeatureToAllTemplate"; + const FEATURE_ADD_TO_ALL_TEMPLATES = "action.removeFeatureFromAllTemplate"; + + const BEFORE_CREATEFEATURE = "action.before_createFeature"; + const AFTER_CREATEFEATURE = "action.after_createFeature"; + + const BEFORE_UPDATEFEATURE = "action.before_updateFeature"; + const AFTER_UPDATEFEATURE = "action.after_updateFeature"; + + const BEFORE_DELETEFEATURE = "action.before_deleteFeature"; + const AFTER_DELETEFEATURE = "action.after_deleteFeature"; + // -- Attributes values management ---------------------------------------- const ATTRIBUTE_AV_CREATE = "action.createAttributeAv"; @@ -401,4 +503,32 @@ final class TheliaEvents const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv"; const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv"; + + + // -- Features values management ---------------------------------------- + + const FEATURE_AV_CREATE = "action.createFeatureAv"; + const FEATURE_AV_UPDATE = "action.updateFeatureAv"; + const FEATURE_AV_DELETE = "action.deleteFeatureAv"; + const FEATURE_AV_UPDATE_POSITION = "action.updateFeatureAvPosition"; + + const BEFORE_CREATEFEATURE_AV = "action.before_createFeatureAv"; + const AFTER_CREATEFEATURE_AV = "action.after_createFeatureAv"; + + const BEFORE_UPDATEFEATURE_AV = "action.before_updateFeatureAv"; + const AFTER_UPDATEFEATURE_AV = "action.after_updateFeatureAv"; + + const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv"; + const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv"; + + /** + * sent when system find a mailer transporter. + */ + const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config'; + + /** + * sent when Thelia try to generate a rewriten url + */ + const GENERATE_REWRITTENURL = 'action.generate_rewritenurl'; + } diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 3bd3147a4..dac1f943d 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -28,8 +28,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Router; use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserInterface; +use Thelia\Exception\OrderException; use Thelia\Tools\Redirect; use Thelia\Tools\URL; use Thelia\Core\Security\Exception\AuthenticationException; @@ -77,16 +79,39 @@ class ViewListener implements EventSubscriberInterface $content = $parser->getContent(); if ($content instanceof Response) { - $event->setResponse($content); + $response = $content;$event->setResponse($content); } else { - $event->setResponse(new Response($content, $parser->getStatus() ?: 200)); + $response = new Response($content, $parser->getStatus() ?: 200); } + + $response->setCache(array( + 'last_modified' => new \DateTime(), + 'max_age' => 600, + 's_maxage' => 600, + 'private' => false, + 'public' => true, + )); + + $event->setResponse($response); } catch (ResourceNotFoundException $e) { $event->setResponse(new Response($e->getMessage(), 404)); } catch (AuthenticationException $ex) { // Redirect to the login template Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate())); + } catch (OrderException $e) { + switch($e->getCode()) { + case OrderException::CART_EMPTY: + // Redirect to the cart template + Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL)); + break; + case OrderException::UNDEFINED_DELIVERY: + // Redirect to the delivery choice template + Redirect::exec($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL)); + break; + } + + throw $e; } } @@ -94,7 +119,7 @@ class ViewListener implements EventSubscriberInterface { $request = $this->container->get('request'); - if (!$view = $request->attributes->get('_view')) { + if (null === $view = $request->attributes->get('_view')) { $request->attributes->set('_view', $this->findView($request)); } diff --git a/core/lib/Thelia/Core/HttpFoundation/Request.php b/core/lib/Thelia/Core/HttpFoundation/Request.php index e86ce8b65..8e77ad865 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Request.php +++ b/core/lib/Thelia/Core/HttpFoundation/Request.php @@ -55,4 +55,15 @@ class Request extends BaseRequest return $uri . $additionalQs; } + + /** + * Gets the Session. + * + * @return \Thelia\Core\HttpFoundation\Session\Session The session + * @api + */ + public function getSession() + { + return parent::getSession(); + } } diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index f2eaadc4d..8a0952ff4 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -29,6 +29,7 @@ use Thelia\Exception\InvalidCartException; use Thelia\Model\CartQuery; use Thelia\Model\Cart; use Thelia\Model\Currency; +use Thelia\Model\Order; use Thelia\Tools\URL; use Thelia\Model\Lang; @@ -43,6 +44,8 @@ use Thelia\Model\Lang; class Session extends BaseSession { /** + * @param bool $forceDefault + * * @return \Thelia\Model\Lang|null */ public function getLang($forceDefault = true) @@ -164,10 +167,12 @@ class Session extends BaseSession $cart = null; if ($cart_id) { $cart = CartQuery::create()->findPk($cart_id); - try { - $this->verifyValidCart($cart); - } catch (InvalidCartException $e) { - $cart = null; + if($cart) { + try { + $this->verifyValidCart($cart); + } catch (InvalidCartException $e) { + $cart = null; + } } } @@ -203,21 +208,46 @@ class Session extends BaseSession return $this; } - /** - * assign delivery id in session - * - * @param $delivery_id - * @return $this - */ - public function setDelivery($delivery_id) + // -- Order ------------------------------------------------------------------ + + + public function setOrder(Order $order) { - $this->set("thelia.delivery_id", $delivery_id); + $this->set("thelia.order", $order); return $this; } - public function getDelivery() + /** + * @return Order + */ + public function getOrder() { - return $this->get("thelia.delivery_id"); + return $this->get("thelia.order"); + } + + + /** + * Set consumed coupons by the Customer + * + * @param array $couponsCode An array of Coupon code + * + * @return $this + */ + public function setConsumedCoupons(array $couponsCode) + { + $this->set('thelia.consumed_coupons', $couponsCode); + + return $this; + } + + /** + * Get Customer consumed coupons + * + * @return array $couponsCode An array of Coupon code + */ + public function getConsumedCoupons() + { + return $this->get('thelia.consumed_coupons'); } } diff --git a/core/lib/Thelia/Core/Routing/RewritingRouter.php b/core/lib/Thelia/Core/Routing/RewritingRouter.php index 2b663a979..9b736a614 100644 --- a/core/lib/Thelia/Core/Routing/RewritingRouter.php +++ b/core/lib/Thelia/Core/Routing/RewritingRouter.php @@ -128,7 +128,7 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface */ public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { - // TODO: Implement generate() method. + throw new RouteNotFoundException(); } /** diff --git a/core/lib/Thelia/Core/Security/Authentication/AdminTokenAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/AdminTokenAuthenticator.php new file mode 100644 index 000000000..4c6dcec5c --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/AdminTokenAuthenticator.php @@ -0,0 +1,37 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +use Thelia\Core\Security\UserProvider\AdminTokenUserProvider; + +class AdminTokenAuthenticator extends TokenAuthenticator +{ + public function __construct($key) + { + parent::__construct( + $key, + new AdminTokenUserProvider() + ); + } +} diff --git a/core/lib/Thelia/Core/Security/Authentication/CustomerTokenAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/CustomerTokenAuthenticator.php new file mode 100644 index 000000000..d06400875 --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/CustomerTokenAuthenticator.php @@ -0,0 +1,37 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +use Thelia\Core\Security\UserProvider\CustomerTokenUserProvider; + +class CustomerTokenAuthenticator extends TokenAuthenticator +{ + public function __construct($key) + { + parent::__construct( + $key, + new CustomerTokenUserProvider() + ); + } +} diff --git a/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php new file mode 100644 index 000000000..1c8c11c73 --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +use Thelia\Core\Security\Authentication\AuthenticatorInterface; +use Thelia\Core\Security\UserProvider\UserProviderInterface; +use Thelia\Core\Security\UserProvider\TokenUserProvider; +use Thelia\Core\Security\Exception\TokenAuthenticationException; + +class TokenAuthenticator implements AuthenticatorInterface +{ + protected $key; + + protected $userProvider; + + public function __construct($key, TokenUserProvider $userProvider) + { + $this->key = $key; + + $this->userProvider = $userProvider; + } + + /** + * @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser() + */ + public function getAuthentifiedUser() + { + $keyData = $this->userProvider->decodeKey($this->key); + + $user = $this->userProvider->getUser($keyData); + + if ($user === null) throw new TokenAuthenticationException("No user matches the provided token"); + + return $user; + } +} diff --git a/core/lib/Thelia/Core/Security/Exception/TokenAuthenticationException.php b/core/lib/Thelia/Core/Security/Exception/TokenAuthenticationException.php new file mode 100644 index 000000000..6af57162d --- /dev/null +++ b/core/lib/Thelia/Core/Security/Exception/TokenAuthenticationException.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Exception; + +class TokenAuthenticationException extends \Exception +{ +} diff --git a/core/lib/Thelia/Core/Security/Token/CookieTokenProvider.php b/core/lib/Thelia/Core/Security/Token/CookieTokenProvider.php new file mode 100644 index 000000000..ee2d9291a --- /dev/null +++ b/core/lib/Thelia/Core/Security/Token/CookieTokenProvider.php @@ -0,0 +1,55 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Token; + +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Security\User\UserInterface; + +class CookieTokenProvider +{ + public function getKeyFromCookie(Request $request, $cookieName) + { + if ($request->cookies->has($cookieName)) { + + // Create the authenticator + return $request->cookies->get($cookieName); + } + + return null; + } + + public function createCookie(UserInterface $user, $cookieName, $cookieExpires) + { + $tokenProvider = new TokenProvider(); + + $key = $tokenProvider->encodeKey($user); + + setcookie($cookieName, $key, time() + $cookieExpires, '/'); + } + + public function clearCookie($cookieName) + { + setcookie($cookieName, '', time() - 3600, '/'); + } +} diff --git a/core/lib/Thelia/Core/Security/Token/TokenProvider.php b/core/lib/Thelia/Core/Security/Token/TokenProvider.php new file mode 100644 index 000000000..e50b60602 --- /dev/null +++ b/core/lib/Thelia/Core/Security/Token/TokenProvider.php @@ -0,0 +1,27 @@ +setToken(uniqid()); + + return base64_encode(serialize( + array($user->getUsername(), $user->getToken(), $user->getSerial()))); + } + + public function decodeKey($key) { + $data = unserialize(base64_decode($key)); + + return array( + 'username' => $data[0], + 'token' => $data[1], + 'serial' => $data[2] + ); + } +} diff --git a/core/lib/Thelia/Core/Security/User/UserInterface.php b/core/lib/Thelia/Core/Security/User/UserInterface.php index 12e07f431..cdff4d44e 100755 --- a/core/lib/Thelia/Core/Security/User/UserInterface.php +++ b/core/lib/Thelia/Core/Security/User/UserInterface.php @@ -48,4 +48,24 @@ interface UserInterface * @return void */ public function eraseCredentials(); -} + + /** + * return the user token (used by remember me authnetication system) + */ + public function getToken(); + + /** + * Set a token in the user data (used by remember me authnetication system) + */ + public function setToken($token); + + /** + * return the user serial (used by remember me authnetication system) + */ + public function getSerial(); + + /** + * Set a serial number int the user data (used by remember me authnetication system) + */ + public function setSerial($serial); +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php new file mode 100644 index 000000000..4567176e5 --- /dev/null +++ b/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\UserProvider; + +use Thelia\Model\Admin; +use Thelia\Model\AdminQuery; + +class AdminTokenUserProvider extends TokenUserProvider +{ + public function getUser($dataArray) { + + return AdminQuery::create() + ->filterByLogin($dataArray['username']) + ->filterByRememberMeSerial($dataArray['serial']) + ->filterByRememberMeToken($dataArray['token']) + ->findOne(); + } +} diff --git a/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php index a889053c4..a6147fca4 100755 --- a/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php @@ -1,4 +1,26 @@ . */ +/* */ +/*************************************************************************************/ + namespace Thelia\Core\Security\UserProvider; use Thelia\Model\Admin; diff --git a/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php new file mode 100644 index 000000000..421d48dd4 --- /dev/null +++ b/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\UserProvider; + +use Thelia\Action\Customer; +use Thelia\Model\CustomerQuery; + +class CustomerTokenUserProvider extends TokenUserProvider +{ + public function getUser($dataArray) { + + return CustomerQuery::create() + ->filterByEmail($dataArray['username']) + ->filterByRememberMeSerial($dataArray['serial']) + ->filterByRememberMeToken($dataArray['token']) + ->findOne(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php index 371af73fc..21db28cab 100755 --- a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php @@ -1,4 +1,26 @@ . */ +/* */ +/*************************************************************************************/ + namespace Thelia\Core\Security\UserProvider; use Thelia\Action\Customer; @@ -13,4 +35,4 @@ class CustomerUserProvider implements UserProviderInterface return $customer; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php new file mode 100644 index 000000000..6c46bcbbb --- /dev/null +++ b/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php @@ -0,0 +1,32 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\UserProvider; + +use Thelia\Core\Security\User\UserInterface; +use Thelia\Core\Security\Token\TokenProvider; + +abstract class TokenUserProvider extends TokenProvider implements UserProviderInterface +{ + public abstract function getUser($key); +} diff --git a/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php b/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php index dd4232ade..6fe5e5197 100755 --- a/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php +++ b/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php @@ -1,4 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Core\Security\UserProvider; diff --git a/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php b/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php index 35077f5c4..557c64901 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php @@ -65,6 +65,8 @@ abstract class BaseI18nLoop extends BaseLoop { /* manage translations */ + $fr = $this->getForce_return(); + return ModelCriteriaTools::getI18n( $this->getBackend_context(), $this->getLang(), @@ -73,7 +75,7 @@ abstract class BaseI18nLoop extends BaseLoop $columns, $foreignTable, $foreignKey, - $forceReturn + $this->getForce_return() ); } } diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index b684d06e2..5ac23142d 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -89,6 +89,7 @@ abstract class BaseLoop Argument::createIntTypeArgument('page'), Argument::createIntTypeArgument('limit', PHP_INT_MAX), Argument::createBooleanTypeArgument('backend_context', false), + Argument::createBooleanTypeArgument('force_return', false), ); } diff --git a/core/lib/Thelia/Core/Template/Element/LoopResult.php b/core/lib/Thelia/Core/Template/Element/LoopResult.php index f86ab203d..3ca1e91d3 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResult.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResult.php @@ -37,7 +37,7 @@ class LoopResult implements \Iterator public function __construct($modelCollection = null) { $this->position = 0; - if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) { + if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager || is_array($modelCollection)) { $this->modelCollection = $modelCollection; } } @@ -57,6 +57,17 @@ class LoopResult implements \Iterator return count($this->collection); } + public function getModelCollectionCount() + { + if ($this->modelCollection instanceof ObjectCollection || $this->modelCollection instanceof PropelModelPager) { + return $this->modelCollection->count(); + } elseif (is_array($this->modelCollection)) { + return count($this->modelCollection); + } else { + return 0; + } + } + /** * (PHP 5 >= 5.0.0)
* Return the current element diff --git a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php index 15bb287b1..9c4f93586 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php @@ -107,7 +107,7 @@ class LoopResultRow } if (true === $this->countable) { $this->set('LOOP_COUNT', 1 + $this->loopResult->getCount()); - $this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count()); + $this->set('LOOP_TOTAL', $this->loopResult->getModelCollectionCount()); } } } diff --git a/core/lib/Thelia/Core/Template/Loop/Accessory.php b/core/lib/Thelia/Core/Template/Loop/Accessory.php index 69b2e09d9..6dc269b62 100755 --- a/core/lib/Thelia/Core/Template/Loop/Accessory.php +++ b/core/lib/Thelia/Core/Template/Loop/Accessory.php @@ -93,8 +93,10 @@ class Accessory extends Product $accessories = $this->search($search); $accessoryIdList = array(0); + $accessoryPosition = array(); foreach ($accessories as $accessory) { array_push($accessoryIdList, $accessory->getAccessory()); + $accessoryPosition[$accessory->getAccessory()] = $accessory->getPosition(); } $receivedIdList = $this->getId(); @@ -106,7 +108,15 @@ class Accessory extends Product $this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $accessoryIdList)) ); } - return parent::exec($pagination); + $loopResult = parent::exec($pagination); + + foreach($loopResult as $loopResultRow) { + $loopResultRow + ->set("POSITION" , $accessoryPosition[$loopResultRow->get('ID')]) + ; + } + + return $loopResult; } } diff --git a/core/lib/Thelia/Core/Template/Loop/Address.php b/core/lib/Thelia/Core/Template/Loop/Address.php index 1321592f4..9ca4352e9 100755 --- a/core/lib/Thelia/Core/Template/Loop/Address.php +++ b/core/lib/Thelia/Core/Template/Loop/Address.php @@ -54,7 +54,13 @@ class Address extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntListTypeArgument('id'), + new Argument( + 'id', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('*', 'any')) + ) + ), new Argument( 'customer', new TypeCollection( @@ -63,8 +69,14 @@ class Address extends BaseLoop ), 'current' ), - Argument::createBooleanTypeArgument('default'), - Argument::createIntListTypeArgument('exclude') + Argument::createBooleanOrBothTypeArgument('default'), + new Argument( + 'exclude', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('none')) + ) + ) ); } @@ -79,7 +91,7 @@ class Address extends BaseLoop $id = $this->getId(); - if (null !== $id) { + if (null !== $id && !in_array($id, array('*', 'any'))) { $search->filterById($id, Criteria::IN); } @@ -106,7 +118,7 @@ class Address extends BaseLoop $exclude = $this->getExclude(); - if (!is_null($exclude)) { + if (null !== $exclude && 'none' !== $exclude) { $search->filterById($exclude, Criteria::NOT_IN); } diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php index 54c2e3bf2..418a76220 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php @@ -58,7 +58,19 @@ class Argument public function setValue($value) { - $this->value = $value === null ? null : (string) $value; + $x = $value === null; + + if($value === null) { + $this->value = null; + } else { + if(false === $value) { + /* (string) $value = "" */ + $this->value = 0; + } else { + $this->value = (string) $value; + } + } + //$this->value = $value === null ? null : (string) $value; } public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true) diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 253c48da7..20fe5cb1e 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -53,8 +53,12 @@ class AssociatedContent extends Content { $argumentCollection = parent::getArgDefinitions(); - $argumentCollection->addArgument(Argument::createIntTypeArgument('product')) - ->addArgument(Argument::createIntTypeArgument('category')); + $argumentCollection + ->addArgument(Argument::createIntTypeArgument('product')) + ->addArgument(Argument::createIntTypeArgument('category')) + ->addArgument(Argument::createIntTypeArgument('exclude_product')) + ->addArgument(Argument::createIntTypeArgument('exclude_category')) + ; $argumentCollection->get('order')->default = "associated_content"; @@ -91,6 +95,28 @@ class AssociatedContent extends Content $search->filterByCategoryId($category, Criteria::EQUAL); } + $exclude_product = $this->getExcludeProduct(); + + // If we have to filter by product, find all products assigned to this product, and filter by found IDs + if (null !== $exclude_product) { + // Exclude all contents related to the given product + $search->filterById( + ProductAssociatedContentQuery::create()->filterByProductId($exclude_product)->select('product_id')->find(), + Criteria::NOT_IN + ); + } + + $exclude_category = $this->getExcludeCategory(); + + // If we have to filter by category, find all contents assigned to this category, and filter by found IDs + if (null !== $exclude_category) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + CategoryAssociatedContentQuery::create()->filterByProductId($exclude_category)->select('category_id')->find(), + Criteria::NOT_IN + ); + } + $order = $this->getOrder(); $orderByAssociatedContent = array_search('associated_content', $order); $orderByAssociatedContentReverse = array_search('associated_content_reverse', $order); diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index cb3a25e17..e2ea7cf0f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -38,6 +38,9 @@ use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; +use Thelia\Model\ProductQuery; +use Thelia\Model\TemplateQuery; +use Thelia\Model\AttributeTemplateQuery; /** * @@ -60,8 +63,8 @@ class Attribute extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('product'), - Argument::createIntListTypeArgument('category'), - Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntListTypeArgument('template'), + Argument::createIntListTypeArgument('exclude_template'), Argument::createIntListTypeArgument('exclude'), new Argument( 'order', @@ -101,27 +104,34 @@ class Attribute extends BaseI18nLoop $search->filterById($exclude, Criteria::NOT_IN); } - $visible = $this->getVisible(); - - if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); - $product = $this->getProduct(); - $category = $this->getCategory(); + $template = $this->getTemplate(); if (null !== $product) { - $productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData(); + // Find the template assigned to the product. + $productObj = ProductQuery::create()->findPk($product); - if (null === $category) { - $category = $productCategories; - } else { - $category = array_merge($category, $productCategories); - } + // Ignore if the product cannot be found. + if ($productObj !== null) + $template = $productObj->getTemplate(); + } + + // If we have to filter by template, find all attributes assigned to this template, and filter by found IDs + if (null !== $template) { + $search->filterById( + AttributeTemplateQuery::create()->filterByTemplateId($template)->select('attribute_id')->find(), + Criteria::IN + ); } - if (null !== $category) { - $search->filterByCategory( - CategoryQuery::create()->filterById($category)->find(), - Criteria::IN + $exclude_template = $this->getExcludeTemplate(); + + // If we have to filter by template, find all attributes assigned to this template, and filter by found IDs + if (null !== $exclude_template) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find(), + Criteria::NOT_IN ); } diff --git a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php index 2aaa173dc..6f5f23707 100644 --- a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php +++ b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php @@ -29,7 +29,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\ModuleQuery; /** - * Class Delivery * @package Thelia\Core\Template\Loop * @author Manuel Raynaud */ @@ -93,6 +92,8 @@ class BaseSpecificModule extends BaseI18nLoop { $search = ModuleQuery::create(); + $search->filterByActivate(1); + if (null !== $id = $this->getId()) { $search->filterById($id); } diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index f65afdf40..5c08b2896 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -13,6 +13,7 @@ use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Model\CountryQuery; class Cart extends BaseLoop { @@ -80,9 +81,11 @@ class Cart extends BaseLoop return $result; } + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic; + foreach ($cartItems as $cartItem) { $product = $cartItem->getProduct(); - //$product->setLocale($this->request->getSession()->getLocale()); + $productSaleElement = $cartItem->getProductSaleElements(); $loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable); @@ -92,10 +95,26 @@ class Cart extends BaseLoop $loopResultRow->set("QUANTITY", $cartItem->getQuantity()); $loopResultRow->set("PRICE", $cartItem->getPrice()); $loopResultRow->set("PRODUCT_ID", $product->getId()); + $loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale())) + ->set("STOCK", $productSaleElement->getQuantity()) + ->set("PRICE", $cartItem->getPrice()) + ->set("PROMO_PRICE", $cartItem->getPromoPrice()) + ->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry)) + ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry)) + ->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0); $result->addRow($loopResultRow); } return $result; } + /** + * Return the event dispatcher, + * + * @return \Symfony\Component\EventDispatcher\EventDispatcher + */ + public function getDispatcher() + { + return $this->dispatcher; + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 2b1156b98..7a0bac76d 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -173,6 +173,22 @@ class Category extends BaseI18nLoop $loopResult = new LoopResult($categories); foreach ($categories as $category) { + + // Find previous and next category + $previous = CategoryQuery::create() + ->filterByParent($category->getParent()) + ->filterByPosition($category->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() + ; + + $next = CategoryQuery::create() + ->filterByParent($category->getParent()) + ->filterByPosition($category->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + /* * no cause pagination lost : * if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; @@ -190,10 +206,17 @@ class Category extends BaseI18nLoop ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $category->getParent()) ->set("URL", $category->getUrl($locale)) - ->set("PRODUCT_COUNT", $category->countChild()) + ->set("PRODUCT_COUNT", $category->countAllProducts()) + ->set("CHILD_COUNT", $category->countChild()) ->set("VISIBLE", $category->getVisible() ? "1" : "0") ->set("POSITION", $category->getPosition()) - ; + + ->set("HAS_PREVIOUS", $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + + ->set("PREVIOUS", $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ; $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index afcd0410e..009e2204f 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php @@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop } // changement de rubrique - protected function buildCategoryTree($parent, $visible, $level, $max_level, array $exclude, LoopResult &$loopResult) + protected function buildCategoryTree($parent, $visible, $level, $previousLevel, $max_level, $exclude, LoopResult &$loopResult) { if ($level > $max_level) return; @@ -73,7 +73,7 @@ class CategoryTree extends BaseI18nLoop if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); - $search->filterById($exclude, Criteria::NOT_IN); + if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN); $search->orderByPosition(Criteria::ASC); @@ -87,11 +87,12 @@ class CategoryTree extends BaseI18nLoop ->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE')) ->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale)) ->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level) + ->set('CHILD_COUNT', $result->countChild())->set('PREV_LEVEL', $previousLevel) ; $loopResult->addRow($loopResultRow); - $this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult); + $this->buildCategoryTree($result->getId(), $visible, 1 + $level, $level, $max_level, $exclude, $loopResult); } } @@ -109,7 +110,7 @@ class CategoryTree extends BaseI18nLoop $loopResult = new LoopResult(); - $this->buildCategoryTree($id, $visible, 0, $depth, $exclude, $loopResult); + $this->buildCategoryTree($id, $visible, 0, 0, $depth, $exclude, $loopResult); return $loopResult; } diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index 2d849b218..0136f4e9c 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -61,6 +61,7 @@ class Content extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('folder'), + Argument::createIntListTypeArgument('folder_default'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('current_folder'), Argument::createIntTypeArgument('depth', 1), @@ -97,9 +98,20 @@ class Content extends BaseI18nLoop } $folder = $this->getFolder(); + $folderDefault = $this->getFolderDefault(); - if (!is_null($folder)) { - $folders = FolderQuery::create()->filterById($folder, Criteria::IN)->find(); + if (!is_null($folder) || !is_null($folderDefault)) { + + $foldersIds = array(); + if (!is_array($folder)) { + $folder = array(); + } + if (!is_array($folderDefault)) { + $folderDefault = array(); + } + + $foldersIds = array_merge($foldersIds, $folder, $folderDefault); + $folders =FolderQuery::create()->filterById($foldersIds, Criteria::IN)->find(); $depth = $this->getDepth(); @@ -164,12 +176,12 @@ class Content extends BaseI18nLoop $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": - if(null === $folder || count($folder) != 1) + if(null === $foldersIds || count($foldersIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single folder argument'); $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - if(null === $folder || count($folder) != 1) + if(null === $foldersIds || count($foldersIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single folder argument'); $search->orderByPosition(Criteria::DESC); break; @@ -222,6 +234,7 @@ class Content extends BaseI18nLoop ->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSITION", $content->getPosition()) + ->set("DEFAULT_FOLDER", $content->getDefaultFolderId()) ->set("URL", $content->getUrl($locale)) ; diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index f14b97efc..3a05b684a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -87,7 +87,7 @@ class Country extends BaseI18nLoop if (true === $withArea) { $search->filterByAreaId(null, Criteria::ISNOTNULL); - } elseif (false == $withArea) { + } elseif (false === $withArea) { $search->filterByAreaId(null, Criteria::ISNULL); } diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 2fb49e8b9..4e8ca3e71 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -24,6 +24,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Util\PropelModelPager; use Thelia\Constraint\ConstraintFactory; use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Core\HttpFoundation\Request; @@ -34,9 +35,11 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\CouponQuery; use Thelia\Model\Coupon as MCoupon; use Thelia\Type; +use Thelia\Type\BooleanOrBothType; /** * Created by JetBrains PhpStorm. @@ -52,17 +55,22 @@ use Thelia\Type; class Coupon extends BaseI18nLoop { /** + * Define all args used in your loop + * * @return ArgumentCollection */ protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntListTypeArgument('id') + Argument::createIntListTypeArgument('id'), + Argument::createBooleanOrBothTypeArgument('is_enabled', 1) ); } /** - * @param $pagination + * Execute Loop + * + * @param PropelModelPager $pagination * * @return \Thelia\Core\Template\Element\LoopResult */ @@ -74,11 +82,16 @@ class Coupon extends BaseI18nLoop $locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION')); $id = $this->getId(); + $isEnabled = $this->getIsEnabled(); if (null !== $id) { $search->filterById($id, Criteria::IN); } + if ($isEnabled != BooleanOrBothType::ANY) { + $search->filterByIsEnabled($isEnabled ? 1 : 0); + } + // Perform search $coupons = $this->search($search, $pagination); @@ -98,9 +111,30 @@ class Coupon extends BaseI18nLoop $coupon->getSerializedRules() ); + /** @var CouponInterface $couponManager */ + $couponManager = $this->container->get($coupon->getType()); + $couponManager->set( + $this->container->get('thelia.adapter'), + $coupon->getCode(), + $coupon->getTitle(), + $coupon->getShortDescription(), + $coupon->getDescription(), + $coupon->getAmount(), + $coupon->getIsCumulative(), + $coupon->getIsRemovingPostage(), + $coupon->getIsAvailableOnSpecialOffers(), + $coupon->getIsEnabled(), + $coupon->getMaxUsage(), + $coupon->getExpirationDate() + ); + + $now = time(); + $datediff = $coupon->getExpirationDate()->getTimestamp() - $now; + $daysLeftBeforeExpiration = floor($datediff/(60*60*24)); + $cleanedRules = array(); /** @var CouponRuleInterface $rule */ - foreach ($rules->getRules() as $key => $rule) { + foreach ($rules->getRules() as $rule) { $cleanedRules[] = $rule->getToolTip(); } $loopResultRow->set("ID", $coupon->getId()) @@ -114,9 +148,13 @@ class Coupon extends BaseI18nLoop ->set("USAGE_LEFT", $coupon->getMaxUsage()) ->set("IS_CUMULATIVE", $coupon->getIsCumulative()) ->set("IS_REMOVING_POSTAGE", $coupon->getIsRemovingPostage()) + ->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $coupon->getIsAvailableOnSpecialOffers()) ->set("IS_ENABLED", $coupon->getIsEnabled()) ->set("AMOUNT", $coupon->getAmount()) - ->set("APPLICATION_CONDITIONS", $cleanedRules); + ->set("APPLICATION_CONDITIONS", $cleanedRules) + ->set("TOOLTIP", $couponManager->getToolTip()) + ->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration) + ->set("SERVICE_ID", $couponManager->getServiceId()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index a0e9ebb7a..5d33d398d 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -22,9 +22,12 @@ /*************************************************************************************/ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\CountryQuery; +use Thelia\Module\BaseModule; /** * Class Delivery @@ -50,6 +53,19 @@ class Delivery extends BaseSpecificModule $search = parent::exec($pagination); /* manage translations */ $locale = $this->configureI18nProcessing($search); + + $search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL); + + $countryId = $this->getCountry(); + if(null !== $countryId) { + $country = CountryQuery::create()->findPk($countryId); + if(null === $country) { + throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop'); + } + } else { + $country = CountryQuery::create()->findOneByByDefault(1); + } + /* perform search */ $deliveryModules = $this->search($search, $pagination); @@ -73,7 +89,7 @@ class Delivery extends BaseSpecificModule ->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO')) ->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION')) ->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set('PRICE', $moduleInstance->calculate($this->getCountry())) + ->set('POSTAGE', $moduleInstance->getPostage($country)) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Document.php b/core/lib/Thelia/Core/Template/Loop/Document.php new file mode 100644 index 000000000..0e7e979c9 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Document.php @@ -0,0 +1,277 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Core\Event\DocumentEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Type\TypeCollection; +use Thelia\Type\EnumListType; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Template\Element\LoopResultRow; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Type\EnumType; +use Thelia\Log\Tlog; + +/** + * The document loop + * + * @author Franck Allimant + */ +class Document extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @var array Possible document sources + */ + protected $possible_sources = array('category', 'product', 'folder', 'content'); + + /** + * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection + */ + protected function getArgDefinitions() + { + $collection = new ArgumentCollection( + + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude'), + new Argument( + 'order', + new TypeCollection( + new EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual-reverse', 'random')) + ), + 'manual' + ), + Argument::createIntTypeArgument('lang'), + + Argument::createIntTypeArgument('category'), + Argument::createIntTypeArgument('product'), + Argument::createIntTypeArgument('folder'), + Argument::createIntTypeArgument('content'), + + new Argument( + 'source', + new TypeCollection( + new EnumType($this->possible_sources) + ) + ), + Argument::createIntTypeArgument('source_id') + ); + + // Add possible document sources + foreach ($this->possible_sources as $source) { + $collection->addArgument(Argument::createIntTypeArgument($source)); + } + + return $collection; + } + + /** + * Dynamically create the search query, and set the proper filter and order + * + * @param string $source a valid source identifier (@see $possible_sources) + * @param int $object_id the source object ID + * @return ModelCriteria the propel Query object + */ + protected function createSearchQuery($source, $object_id) + { + $object = ucfirst($source); + + $queryClass = sprintf("\Thelia\Model\%sDocumentQuery", $object); + $filterMethod = sprintf("filterBy%sId", $object); + + // xxxDocumentQuery::create() + $method = new \ReflectionMethod($queryClass, 'create'); + $search = $method->invoke(null); // Static ! + + // $query->filterByXXX(id) + if (! is_null($object_id)) { + $method = new \ReflectionMethod($queryClass, $filterMethod); + $method->invoke($search, $object_id); + } + + $orders = $this->getOrder(); + + // Results ordering + foreach ($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case "alpha-reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + case "manual-reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); + break; + } + } + + return $search; + } + + /** + * Dynamically create the search query, and set the proper filter and order + * + * @param string $object_type (returned) the a valid source identifier (@see $possible_sources) + * @param string $object_id (returned) the ID of the source object + * @return ModelCriteria the propel Query object + */ + protected function getSearchQuery(&$object_type, &$object_id) + { + $search = null; + + // Check form source="product" source_id="123" style arguments + $source = $this->getSource(); + + if (! is_null($source)) { + + $source_id = $this->getSourceId(); + $id = $this->getId(); + + // echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."
"; + + if (is_null($source_id) && is_null($id)) { + throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified"); + } + + $search = $this->createSearchQuery($source, $source_id); + + $object_type = $source; + $object_id = $source_id; + } else { + // Check for product="id" folder="id", etc. style arguments + foreach ($this->possible_sources as $source) { + + $argValue = intval($this->getArgValue($source)); + + if ($argValue > 0) { + + $search = $this->createSearchQuery($source, $argValue); + + $object_type = $source; + $object_id = $argValue; + + break; + } + } + } + + if ($search == null) + throw new \InvalidArgumentException(sprintf("Unable to find document source. Valid sources are %s", implode(',', $this->possible_sources))); + + return $search; + } + + /** + * @param unknown $pagination + */ + public function exec(&$pagination) + { + // Select the proper query to use, and get the object type + $object_type = $object_id = null; + + $search = $this->getSearchQuery($object_type, $object_id); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (! is_null($id)) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + if (!is_null($exclude)) + $search->filterById($exclude, Criteria::NOT_IN); + + // Create document processing event + $event = new DocumentEvent($this->request); + + // echo "sql=".$search->toString(); + + $results = $this->search($search, $pagination); + + $loopResult = new LoopResult($results); + + foreach ($results as $result) { + + // Create document processing event + $event = new DocumentEvent($this->request); + + // Put source document file path + $source_filepath = sprintf("%s%s/%s/%s", + THELIA_ROOT, + ConfigQuery::read('documents_library_path', 'local/media/documents'), + $object_type, + $result->getFile() + ); + + $event->setSourceFilepath($source_filepath); + $event->setCacheSubdirectory($object_type); + + try { + // Dispatch document processing event + $this->dispatcher->dispatch(TheliaEvents::DOCUMENT_PROCESS, $event); + + $loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("ID" , $result->getId()) + ->set("LOCALE" ,$locale) + ->set("DOCUMENT_URL" , $event->getFileUrl()) + ->set("DOCUMENT_PATH" , $event->getCacheFilepath()) + ->set("ORIGINAL_DOCUMENT_PATH", $source_filepath) + ->set("TITLE" , $result->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $result->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("POSITION" , $result->getPosition()) + ->set("OBJECT_TYPE" , $object_type) + ->set("OBJECT_ID" , $object_id) + ; + + $loopResult->addRow($loopResultRow); + } + catch (\Exception $ex) { + // Ignore the result and log an error + Tlog::getInstance()->addError("Failed to process document in document loop: ", $this->args); + } + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 7f412e4b0..380333e38 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -31,13 +31,16 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Base\CategoryQuery; -use Thelia\Model\Base\ProductCategoryQuery; -use Thelia\Model\Base\FeatureQuery; +use Thelia\Model\CategoryQuery; +use Thelia\Model\FeatureI18nQuery; +use Thelia\Model\ProductCategoryQuery; +use Thelia\Model\FeatureQuery; use Thelia\Model\Map\ProductCategoryTableMap; +use Thelia\Model\ProductQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; +use Thelia\Model\FeatureTemplateQuery; /** * @@ -60,7 +63,8 @@ class Feature extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('product'), - Argument::createIntListTypeArgument('category'), + Argument::createIntListTypeArgument('template'), + Argument::createIntListTypeArgument('exclude_template'), Argument::createBooleanOrBothTypeArgument('visible', 1), Argument::createIntListTypeArgument('exclude'), new Argument( @@ -69,7 +73,8 @@ class Feature extends BaseI18nLoop new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual_reverse')) ), 'manual' - ) + ), + Argument::createAnyTypeArgument('title') ); } @@ -102,25 +107,53 @@ class Feature extends BaseI18nLoop if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); $product = $this->getProduct(); - $category = $this->getCategory(); + $template = $this->getTemplate(); if (null !== $product) { - $productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData(); + // Find the template assigned to the product. + $productObj = ProductQuery::create()->findPk($product); - if (null === $category) { - $category = $productCategories; - } else { - $category = array_merge($category, $productCategories); - } - } + // Ignore if the product cannot be found. + if ($productObj !== null) + $template = $productObj->getTemplate(); + } - if (null !== $category) { - $search->filterByCategory( - CategoryQuery::create()->filterById($category)->find(), + // If we have to filter by template, find all features assigned to this template, and filter by found IDs + if (null !== $template) { + $search->filterById( + FeatureTemplateQuery::create()->filterByTemplateId($template)->select('feature_id')->find(), Criteria::IN ); } + $exclude_template = $this->getExcludeTemplate(); + + // If we have to filter by template, find all features assigned to this template, and filter by found IDs + if (null !== $exclude_template) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + FeatureTemplateQuery::create()->filterByTemplateId($exclude_template)->select('feature_id')->find(), + Criteria::NOT_IN + ); + } + + $title = $this->getTitle(); + + if (null !== $title) { + //find all feture that match exactly this title and find with all locales. + $features = FeatureI18nQuery::create() + ->filterByTitle($title, Criteria::LIKE) + ->select('id') + ->find(); + + if($features) { + $search->filterById( + $features, + Criteria::IN + ); + } + } + $orders = $this->getOrder(); foreach ($orders as $order) { diff --git a/core/lib/Thelia/Core/Template/Loop/Feed.php b/core/lib/Thelia/Core/Template/Loop/Feed.php index 8e155a666..cf29cf3b7 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feed.php +++ b/core/lib/Thelia/Core/Template/Loop/Feed.php @@ -73,9 +73,14 @@ class Feed extends BaseLoop $limit = min(count($items), $this->getLimit()); - $loopResult = new LoopResult(); - + $indexes = array(); for ($idx = 0; $idx < $limit; $idx++) { + $indexes[] = $idx; + } + + $loopResult = new LoopResult($indexes); + + foreach ($indexes as $idx) { $item = $items[$idx]; @@ -87,7 +92,7 @@ class Feed extends BaseLoop $date = $item->get_date('d/m/Y'); - $loopResultRow = new LoopResultRow(); + $loopResultRow = new LoopResultRow($loopResult, null, $this->versionable, $this->timestampable, $this->countable); $loopResultRow->set("URL", $item->get_permalink()); $loopResultRow->set("TITLE", $item->get_title()); diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index cfd54db4f..5c56dff94 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -162,7 +162,8 @@ class Folder extends BaseI18nLoop ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $folder->getParent()) ->set("URL", $folder->getUrl($locale)) - ->set("CONTENT_COUNT", $folder->countChild()) + ->set("CHILD_COUNT", $folder->countChild()) + ->set("CONTENT_COUNT", $folder->countAllContents()) ->set("VISIBLE", $folder->getVisible() ? "1" : "0") ->set("POSITION", $folder->getPosition()) ; diff --git a/core/lib/Thelia/Core/Template/Loop/FolderTree.php b/core/lib/Thelia/Core/Template/Loop/FolderTree.php new file mode 100644 index 000000000..9549f2467 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/FolderTree.php @@ -0,0 +1,118 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\FolderQuery; +use Thelia\Type; +use Thelia\Type\BooleanOrBothType; +use Thelia\Core\Template\Element\BaseI18nLoop; + +/** + * + * Folder tree loop, to get a folder tree from a given folder to a given depth. + * + * - folder is the folder id + * - depth is the maximum depth to go, default unlimited + * - visible if true or missing, only visible categories will be displayed. If false, all categories (visible or not) are returned. + * + * @package Thelia\Core\Template\Loop + * @author Franck Allimant + */ +class FolderTree extends BaseI18nLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('folder', null, true), + Argument::createIntTypeArgument('depth', PHP_INT_MAX), + Argument::createBooleanOrBothTypeArgument('visible', true, false), + Argument::createIntListTypeArgument('exclude', array()) + ); + } + + // changement de rubrique + protected function buildFolderTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult) + { + if ($level > $max_level) return; + + $search = FolderQuery::create(); + + $locale = $this->configureI18nProcessing($search, array( + 'TITLE' + )); + + $search->filterByParent($parent); + + if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); + + if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN); + + $search->orderByPosition(Criteria::ASC); + + $results = $search->find(); + + foreach ($results as $result) { + + $loopResultRow = new LoopResultRow(); + + $loopResultRow + ->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE')) + ->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale)) + ->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level) + ; + + $loopResult->addRow($loopResultRow); + + $this->buildFolderTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult); + } + } + + /** + * @param $pagination (ignored) + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $id = $this->getFolder(); + $depth = $this->getDepth(); + $visible = $this->getVisible(); + $exclude = $this->getExclude(); + + $loopResult = new LoopResult(); + + $this->buildFolderTree($id, $visible, 0, $depth, $exclude, $loopResult); + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index c7714731b..a62f23702 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -48,7 +48,7 @@ class Image extends BaseI18nLoop /** * @var array Possible image sources */ - protected $possible_sources = array('category', 'product', 'folder', 'content'); + protected $possible_sources = array('category', 'product', 'folder', 'content', 'module'); /** * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection @@ -93,7 +93,8 @@ class Image extends BaseI18nLoop new EnumType($this->possible_sources) ) ), - Argument::createIntTypeArgument('source_id') + Argument::createIntTypeArgument('source_id'), + Argument::createBooleanTypeArgument('force_return', true) ); // Add possible image sources @@ -123,8 +124,10 @@ class Image extends BaseI18nLoop $search = $method->invoke(null); // Static ! // $query->filterByXXX(id) - $method = new \ReflectionMethod($queryClass, $filterMethod); - $method->invoke($search, $object_id); + if (! is_null($object_id)) { + $method = new \ReflectionMethod($queryClass, $filterMethod); + $method->invoke($search, $object_id); + } $orders = $this->getOrder(); @@ -171,11 +174,12 @@ class Image extends BaseI18nLoop if (! is_null($source)) { $source_id = $this->getSourceId(); + $id = $this->getId(); - // echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."
"; + //echo "source = ".$this->getSourceId()."source_id=$source_id, id=$id
"; - if (is_null($source_id)) { - throw new \InvalidArgumentException("'source_id' argument cannot be null if 'source' argument is specified."); + if (is_null($source_id) && is_null($id)) { + throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified"); } $search = $this->createSearchQuery($source, $source_id); @@ -211,6 +215,7 @@ class Image extends BaseI18nLoop */ public function exec(&$pagination) { + // Select the proper query to use, and get the object type $object_type = $object_id = null; @@ -282,7 +287,7 @@ class Image extends BaseI18nLoop // Put source image file path $source_filepath = sprintf("%s%s/%s/%s", THELIA_ROOT, - ConfigQuery::read('documents_library_path', 'local/media/images'), + ConfigQuery::read('images_library_path', 'local/media/images'), $object_type, $result->getFile() ); @@ -313,7 +318,8 @@ class Image extends BaseI18nLoop ; $loopResult->addRow($loopResultRow); - } catch (\Exception $ex) { + } + catch (\Exception $ex) { // Ignore the result and log an error Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args); } diff --git a/core/lib/Thelia/Core/Template/Loop/Module.php b/core/lib/Thelia/Core/Template/Loop/Module.php new file mode 100755 index 000000000..1c4f91b4d --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Module.php @@ -0,0 +1,137 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\ModuleQuery; + +use Thelia\Module\BaseModule; +use Thelia\Type; + +/** + * + * Module loop + * + * + * Class Module + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Module extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'module_type', + new Type\TypeCollection( + new Type\EnumListType(array( + BaseModule::CLASSIC_MODULE_TYPE, + BaseModule::DELIVERY_MODULE_TYPE, + BaseModule::PAYMENT_MODULE_TYPE, + )) + ) + ), + Argument::createIntListTypeArgument('exclude'), + Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = ModuleQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $moduleType = $this->getModule_type(); + + if (null !== $moduleType) { + $search->filterByType($moduleType, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $active = $this->getActive(); + + if($active !== Type\BooleanOrBothType::ANY) { + $search->filterByActivate($active ? 1 : 0, Criteria::EQUAL); + } + + $search->orderByPosition(); + + /* perform search */ + $modules = $this->search($search, $pagination); + + $loopResult = new LoopResult($modules); + + foreach ($modules as $module) { + $loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $module->getId()) + ->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("TITLE",$module->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("CODE", $module->getCode()) + ->set("TYPE", $module->getType()) + ->set("ACTIVE", $module->getActivate()) + ->set("CLASS", $module->getFullNamespace()) + ->set("POSITION", $module->getPosition()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index fd11d8d4c..41d49c4f8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -23,12 +23,16 @@ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Model\OrderQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; /** * * @package Thelia\Core\Template\Loop @@ -37,19 +41,94 @@ use Thelia\Core\Template\Loop\Argument\Argument; */ class Order extends BaseLoop { + public $countable = true; + public $timestampable = true; + public $versionable = false; + public function getArgDefinitions() { - return new ArgumentCollection(); + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'customer', + new TypeCollection( + new Type\IntType(), + new Type\EnumType(array('current')) + ), + 'current' + ), + Argument::createIntListTypeArgument('status') + ); } /** + * @param $pagination * - * - * @return \Thelia\Core\Template\Element\LoopResult + * @return LoopResult */ public function exec(&$pagination) { - // TODO : a coder ! - return new LoopResult(); + $search = OrderQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $customer = $this->getCustomer(); + + if ($customer === 'current') { + $currentCustomer = $this->securityContext->getCustomerUser(); + if ($currentCustomer === null) { + return new LoopResult(); + } else { + $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); + } + } else { + $search->filterByCustomerId($customer, Criteria::EQUAL); + } + + $status = $this->getStatus(); + + if (null !== $status) { + $search->filterByStatusId($status, Criteria::IN); + } + + $orders = $this->search($search, $pagination); + + $loopResult = new LoopResult($orders); + + foreach ($orders as $order) { + $tax = 0; + $amount = $order->getTotalAmount($tax); + $loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow + ->set("ID", $order->getId()) + ->set("REF", $order->getRef()) + ->set("CUSTOMER", $order->getCustomerId()) + ->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId()) + ->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId()) + ->set("INVOICE_DATE", $order->getInvoiceDate()) + ->set("CURRENCY", $order->getCurrencyId()) + ->set("CURRENCY_RATE", $order->getCurrencyRate()) + ->set("TRANSACTION_REF", $order->getTransactionRef()) + ->set("DELIVERY_REF", $order->getDeliveryRef()) + ->set("INVOICE_REF", $order->getInvoiceRef()) + ->set("POSTAGE", $order->getPostage()) + ->set("PAYMENT_MODULE", $order->getPaymentModuleId()) + ->set("DELIVERY_MODULE", $order->getDeliveryModuleId()) + ->set("STATUS", $order->getStatusId()) + ->set("LANG", $order->getLangId()) + ->set("POSTAGE", $order->getPostage()) + ->set("TOTAL_TAX", $tax) + ->set("TOTAL_AMOUNT", $amount - $tax) + ->set("TOTAL_TAXED_AMOUNT", $amount) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; } } diff --git a/core/lib/Thelia/Core/Template/Loop/Payment.php b/core/lib/Thelia/Core/Template/Loop/Payment.php new file mode 100644 index 000000000..542ffb590 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Payment.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Module\BaseModule; + +/** + * Class Payment + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Payment extends BaseSpecificModule +{ + + public function getArgDefinitions() + { + $collection = parent::getArgDefinitions(); + + return $collection; + } + + public function exec(&$pagination) + { + $search = parent::exec($pagination); + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $search->filterByType(BaseModule::PAYMENT_MODULE_TYPE, Criteria::EQUAL); + + /* perform search */ + $paymentModules = $this->search($search, $pagination); + + $loopResult = new LoopResult($paymentModules); + + foreach ($paymentModules as $paymentModule) { + $loopResultRow = new LoopResultRow($loopResult, $paymentModule, $this->versionable, $this->timestampable, $this->countable); + + $moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); + if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) { + throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode())); + } + $moduleInstance = $moduleReflection->newInstance(); + + $moduleInstance->setRequest($this->request); + $moduleInstance->setDispatcher($this->dispatcher); + + $loopResultRow + ->set('ID', $paymentModule->getId()) + ->set('TITLE', $paymentModule->getVirtualColumn('i18n_TITLE')) + ->set('CHAPO', $paymentModule->getVirtualColumn('i18n_CHAPO')) + ->set('DESCRIPTION', $paymentModule->getVirtualColumn('i18n_DESCRIPTION')) + ->set('POSTSCRIPTUM', $paymentModule->getVirtualColumn('i18n_POSTSCRIPTUM')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index f6ab423ab..9deade5cc 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -32,6 +32,7 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Exception\TaxEngineException; use Thelia\Model\CategoryQuery; use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; @@ -73,6 +74,7 @@ class Product extends BaseI18nLoop ) ), Argument::createIntListTypeArgument('category'), + Argument::createIntListTypeArgument('category_default'), Argument::createBooleanTypeArgument('new'), Argument::createBooleanTypeArgument('promo'), Argument::createFloatTypeArgument('min_price'), @@ -88,7 +90,7 @@ class Product extends BaseI18nLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id')) + new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id')) ), 'alpha' ), @@ -170,9 +172,20 @@ class Product extends BaseI18nLoop } $category = $this->getCategory(); + $categoryDefault = $this->getCategoryDefault(); - if (!is_null($category)) { - $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); + if (!is_null($category) ||!is_null($categoryDefault)) { + + $categoryIds = array(); + if (!is_array($category)) { + $category = array(); + } + if (!is_array($categoryDefault)) { + $categoryDefault = array(); + } + + $categoryIds = array_merge($categoryIds, $category, $categoryDefault); + $categories =CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find(); $depth = $this->getDepth(); @@ -527,6 +540,12 @@ class Product extends BaseI18nLoop foreach ($orders as $order) { switch ($order) { + case "id": + $search->orderById(Criteria::ASC); + break; + case "id_reverse": + $search->orderById(Criteria::DESC); + break; case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); break; @@ -540,12 +559,12 @@ class Product extends BaseI18nLoop $search->addDescendingOrderByColumn('real_lowest_price'); break; case "manual": - if(null === $category || count($category) != 1) + if(null === $categoryIds || count($categoryIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - if(null === $category || count($category) != 1) + if(null === $categoryIds || count($categoryIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); $search->orderByPosition(Criteria::DESC); break; @@ -579,32 +598,66 @@ class Product extends BaseI18nLoop $loopResult = new LoopResult($products); + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic + foreach ($products as $product) { + $loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable); $price = $product->getRealLowestPrice(); - $taxedPrice = $product->getTaxedPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - ); + try { + $taxedPrice = $product->getTaxedPrice( + $taxCountry + ); + } catch(TaxEngineException $e) { + $taxedPrice = null; + } - $loopResultRow->set("ID", $product->getId()) - ->set("REF",$product->getRef()) - ->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE",$locale) - ->set("TITLE",$product->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("URL", $product->getUrl($locale)) - ->set("BEST_PRICE", $price) - ->set("BEST_PRICE_TAX", $taxedPrice - $price) - ->set("BEST_TAXED_PRICE", $taxedPrice) - ->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo')) - ->set("IS_NEW", $product->getVirtualColumn('main_product_is_new')) - ->set("POSITION", $product->getPosition()) + // Find previous and next product, in the default category. + $default_category_id = $product->getDefaultCategoryId(); + + $previous = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() ; + $next = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + + $loopResultRow + ->set("ID" , $product->getId()) + ->set("REF" , $product->getRef()) + ->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("TITLE" , $product->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("URL" , $product->getUrl($locale)) + ->set("BEST_PRICE" , $price) + ->set("BEST_PRICE_TAX" , $taxedPrice - $price) + ->set("BEST_TAXED_PRICE" , $taxedPrice) + ->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo')) + ->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new')) + ->set("POSITION" , $product->getPosition()) + ->set("VISIBLE" , $product->getVisible() ? "1" : "0") + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ->set("DEFAULT_CATEGORY" , $default_category_id) + + ; + $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index 980ade454..8fb044556 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -31,6 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Exception\TaxEngineException; use Thelia\Model\Base\ProductSaleElementsQuery; use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; @@ -115,7 +116,7 @@ class ProductSaleElements extends BaseLoop $currencyId = $this->getCurrency(); if (null !== $currencyId) { - $currency = CurrencyQuery::create()->findOneById($currencyId); + $currency = CurrencyQuery::create()->findPk($currencyId); if (null === $currency) { throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); } @@ -147,17 +148,27 @@ class ProductSaleElements extends BaseLoop $loopResult = new LoopResult($PSEValues); + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic + foreach ($PSEValues as $PSEValue) { $loopResultRow = new LoopResultRow($loopResult, $PSEValue, $this->versionable, $this->timestampable, $this->countable); $price = $PSEValue->getPrice(); - $taxedPrice = $PSEValue->getTaxedPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - ); + try { + $taxedPrice = $PSEValue->getTaxedPrice( + $taxCountry + ); + } catch(TaxEngineException $e) { + $taxedPrice = null; + } $promoPrice = $PSEValue->getPromoPrice(); - $taxedPromoPrice = $PSEValue->getTaxedPromoPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - ); + try { + $taxedPromoPrice = $PSEValue->getTaxedPromoPrice( + $taxCountry + ); + } catch(TaxEngineException $e) { + $taxedPromoPrice = null; + } $loopResultRow->set("ID", $PSEValue->getId()) ->set("QUANTITY", $PSEValue->getQuantity()) diff --git a/core/lib/Thelia/Core/Template/Loop/TaxRule.php b/core/lib/Thelia/Core/Template/Loop/TaxRule.php new file mode 100644 index 000000000..5851f631d --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/TaxRule.php @@ -0,0 +1,135 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Type\TypeCollection; +use Thelia\Type; +use Thelia\Model\TaxRuleQuery; + +/** + * + * TaxRule loop + * + * + * Class TaxRule + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class TaxRule extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude'), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse')) + ), + 'alpha' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = TaxRuleQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION')); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $orders = $this->getOrder(); + + foreach ($orders as $order) { + switch ($order) { + case "id": + $search->orderById(Criteria::ASC); + break; + case "id_reverse": + $search->orderById(Criteria::DESC); + break; + case "alpha": + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + } + } + + /* perform search */ + $tax_rules = $this->search($search, $pagination); + + $loopResult = new LoopResult($tax_rules); + + foreach ($tax_rules as $tax_rule) { + + $loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("ID" , $tax_rule->getId()) + ->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE')) + ->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION')) + ->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0') + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Template.php b/core/lib/Thelia/Core/Template/Loop/Template.php new file mode 100644 index 000000000..db8bca7ee --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Template.php @@ -0,0 +1,114 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\Base\CategoryQuery; +use Thelia\Model\Base\ProductCategoryQuery; +use Thelia\Model\Base\TemplateQuery; +use Thelia\Model\Map\ProductCategoryTableMap; +use Thelia\Type\TypeCollection; +use Thelia\Type; +use Thelia\Type\BooleanOrBothType; + +/** + * + * Template loop + * + * + * Class Template + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Template extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = TemplateQuery::create(); + + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search, $columns = array('NAME')); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + /* perform search */ + $templates = $this->search($search, $pagination); + + $loopResult = new LoopResult($templates); + + foreach ($templates as $template) { + $loopResultRow = new LoopResultRow($loopResult, $template, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("ID", $template->getId()) + ->set("IS_TRANSLATED" , $template->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("NAME" , $template->getVirtualColumn('i18n_NAME')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 6f83bdcfd..f39c2a768 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -24,6 +24,7 @@ namespace Thelia\Core\Template\Smarty\Plugins; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; use Symfony\Component\HttpFoundation\Request; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Security\SecurityContext; @@ -31,12 +32,14 @@ use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Model\CategoryQuery; use Thelia\Model\ContentQuery; +use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; use Thelia\Model\FolderQuery; use Thelia\Model\Product; use Thelia\Model\ProductQuery; use Thelia\Model\Tools\ModelCriteriaTools; use Thelia\Tools\DateTimeFormat; +use Thelia\Cart\CartTrait; /** * Implementation of data access to main Thelia objects (users, cart, etc.) @@ -46,15 +49,21 @@ use Thelia\Tools\DateTimeFormat; */ class DataAccessFunctions extends AbstractSmartyPlugin { + use CartTrait; + private $securityContext; protected $parserContext; protected $request; + protected $dispatcher; - public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext) + private static $dataAccessCache = array(); + + public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher) { $this->securityContext = $securityContext; $this->parserContext = $parserContext; $this->request = $request; + $this->dispatcher = $dispatcher; } /** @@ -151,11 +160,74 @@ class DataAccessFunctions extends AbstractSmartyPlugin } } + public function countryDataAccess($params, $smarty) + { + if(array_key_exists('defaultCountry', self::$dataAccessCache)) { + $defaultCountry = self::$dataAccessCache['defaultCountry']; + } else { + $defaultCountry = CountryQuery::create()->findOneByByDefault(1); + self::$dataAccessCache['defaultCountry'] = $defaultCountry; + } + + switch($params["attr"]) { + case "default": + return $defaultCountry->getId(); + } + } + + public function cartDataAccess($params, $smarty) + { + if(array_key_exists('currentCountry', self::$dataAccessCache)) { + $currentCountry = self::$dataAccessCache['currentCountry']; + } else { + $currentCountry = CountryQuery::create()->findOneById(64); // @TODO : make it magic + self::$dataAccessCache['currentCountry'] = $currentCountry; + } + + $cart = $this->getCart($this->request); + $result = ""; + switch($params["attr"]) { + case "count_item": + $result = $cart->getCartItems()->count(); + break; + case "total_price": + $result = $cart->getTotalAmount(); + break; + case "total_taxed_price": + $result = $cart->getTaxedAmount($currentCountry); + break; + } + + return $result; + } + + public function orderDataAccess($params, &$smarty) + { + $order = $this->request->getSession()->getOrder(); + $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr')); + switch($attribute) { + case 'postage': + return $order->getPostage(); + case 'delivery_address': + return $order->chosenDeliveryAddress; + case 'invoice_address': + return $order->chosenInvoiceAddress; + case 'delivery_module': + return $order->getDeliveryModuleId(); + case 'payment_module': + return $order->getPaymentModuleId(); + } + + throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute)); + } + /** * Lang global data * * @param $params * @param $smarty + * + * @return string */ public function langDataAccess($params, $smarty) { @@ -174,24 +246,30 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') { - $lang = $this->getNormalizedParam($params, array('lang')); - if ($lang === null) { - $lang = $this->request->getSession()->getLang()->getId(); + if(array_key_exists('data_' . $objectLabel, self::$dataAccessCache)) { + $data = self::$dataAccessCache['data_' . $objectLabel]; + } else { + $lang = $this->getNormalizedParam($params, array('lang')); + if ($lang === null) { + $lang = $this->request->getSession()->getLang()->getId(); + } + + ModelCriteriaTools::getI18n( + false, + $lang, + $search, + $this->request->getSession()->getLang()->getLocale(), + $columns, + $foreignTable, + $foreignKey, + true + ); + + $data = $search->findOne(); + + self::$dataAccessCache['data_' . $objectLabel] = $data; } - ModelCriteriaTools::getI18n( - false, - $lang, - $search, - $this->request->getSession()->getLang()->getLocale(), - $columns, - $foreignTable, - $foreignKey, - true - ); - - $data = $search->findOne(); - $noGetterData = array(); foreach ($columns as $column) { $noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column); @@ -254,6 +332,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function getPluginDescriptors() { + return array( new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'), new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'), @@ -262,7 +341,20 @@ class DataAccessFunctions extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'), new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'), new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'), + new SmartyPluginDescriptor('function', 'country', $this, 'countryDataAccess'), new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'), + new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'), + new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'), ); } + + /** + * Return the event dispatcher, + * + * @return \Symfony\Component\EventDispatcher\EventDispatcher + */ + public function getDispatcher() + { + return $this->dispatcher; + } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 2d5324644..4c953be3c 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -145,7 +145,7 @@ class Form extends AbstractSmartyPlugin public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat) { - if ($repeat) { + if ($repeat) { $formFieldView = $this->getFormFieldView($params); @@ -153,25 +153,25 @@ class Form extends AbstractSmartyPlugin $value = $formFieldView->vars["value"]; /* FIXME: doesnt work. We got "This form should not contain extra fields." error. - // We have a collection - if (is_array($value)) { +// We have a collection +if (is_array($value)) { - $key = $this->getParam($params, 'value_key'); +$key = $this->getParam($params, 'value_key'); - if ($key != null) { +if ($key != null) { - if (isset($value[$key])) { +if (isset($value[$key])) { - $name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key); - $val = $value[$key]; +$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key); +$val = $value[$key]; - $this->assignFieldValues($template, $name, $val, $formFieldView->vars); - } - } - } - else { - $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars); - } +$this->assignFieldValues($template, $name, $val, $formFieldView->vars); +} +} +} +else { +$this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars); +} */ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $formFieldView->vars["value"], $formFieldView->vars); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 24d2c29ee..1492f45cd 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -23,18 +23,24 @@ namespace Thelia\Core\Template\Smarty\Plugins; +use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Security\SecurityContext; use Thelia\Core\Security\Exception\AuthenticationException; +use Thelia\Exception\OrderException; +use Thelia\Model\AddressQuery; +use Thelia\Model\ModuleQuery; class Security extends AbstractSmartyPlugin { + protected $request; private $securityContext; - public function __construct(SecurityContext $securityContext) + public function __construct(Request $request, SecurityContext $securityContext) { $this->securityContext = $securityContext; + $this->request = $request; } /** @@ -43,32 +49,58 @@ class Security extends AbstractSmartyPlugin * @param array $params * @param unknown $smarty * @return string no text is returned. + * @throws \Thelia\Core\Security\Exception\AuthenticationException */ public function checkAuthFunction($params, &$smarty) { - $roles = $this->_explode($this->getParam($params, 'roles')); - $permissions = $this->_explode($this->getParam($params, 'permissions')); + $roles = $this->_explode($this->getParam($params, 'roles')); + $permissions = $this->_explode($this->getParam($params, 'permissions')); - if (! $this->securityContext->isGranted($roles, $permissions)) { + if (! $this->securityContext->isGranted($roles, $permissions)) { - $ex = new AuthenticationException( - sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", - implode(',', $roles), implode(',', $permissions), $context - ) - ); + $ex = new AuthenticationException( + sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", + implode(',', $roles), implode(',', $permissions), $context + ) + ); - $loginTpl = $this->getParam($params, 'login_tpl'); + $loginTpl = $this->getParam($params, 'login_tpl'); - if (null != $loginTpl) { - $ex->setLoginTemplate($loginTpl); - } + if (null != $loginTpl) { + $ex->setLoginTemplate($loginTpl); + } - throw $ex; - } + throw $ex; + } - return ''; + return ''; } + public function checkCartNotEmptyFunction($params, &$smarty) + { + $cart = $this->request->getSession()->getCart(); + if($cart===null || $cart->countCartItems() == 0) { + throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1)); + } + + return ""; + } + + public function checkValidDeliveryFunction($params, &$smarty) + { + $order = $this->request->getSession()->getOrder(); + /* Does address and module still exists ? We assume address owner can't change neither module type */ + if($order !== null) { + $checkAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress); + $checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId()); + } + if(null === $order || null == $checkAddress || null === $checkModule) { + throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1)); + } + + return ""; + } + /** * Define the various smarty plugins handled by this class * @@ -77,7 +109,9 @@ class Security extends AbstractSmartyPlugin public function getPluginDescriptors() { return array( - new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction') + new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction'), + new SmartyPluginDescriptor('function', 'check_cart_not_empty', $this, 'checkCartNotEmptyFunction'), + new SmartyPluginDescriptor('function', 'check_valid_delivery', $this, 'checkValidDeliveryFunction'), ); } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index 37801f4c8..bd2c10513 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -132,6 +132,8 @@ class TheliaLoop extends AbstractSmartyPlugin $loopResults = $loop->exec(self::$pagination[$name]); + $loopResults->rewind(); + $this->loopstack[$name] = $loopResults; // Pas de résultat ? la boucle est terminée, ne pas évaluer le contenu. diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index 56c853d00..f1249697a 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -27,6 +27,7 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Tools\URL; use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Translation\Translator; class UrlGenerator extends AbstractSmartyPlugin { @@ -47,11 +48,27 @@ class UrlGenerator extends AbstractSmartyPlugin public function generateUrlFunction($params, &$smarty) { // the path to process - $path = $this->getParam($params, 'path'); + $path = $this->getParam($params, 'path', null); + $file = $this->getParam($params, 'file', null); + + if ($file !== null) { + $path = $file; + $mode = URL::PATH_TO_FILE; + } + else if ($path !== null) { + $mode = URL::WITH_INDEX_PAGE; + } + else { + throw \InvalidArgumentException(Translator::getInstance()->trans("Please specify either 'path' or 'file' parameter in {url} function.")); + } $target = $this->getParam($params, 'target', null); - $url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target'))); + $url = URL::getInstance()->absoluteUrl( + $path, + $this->getArgsFromParam($params, array('path', 'file', 'target')), + $mode + ); if ($target != null) $url .= '#'.$target; @@ -169,7 +186,8 @@ class UrlGenerator extends AbstractSmartyPlugin protected function getCurrentUrl() { - return URL::getInstance()->retrieveCurrent($this->request)->toString(); + //return URL::getInstance()->retrieveCurrent($this->request)->toString(); + return $this->request->getUri(); } protected function getReturnToUrl() diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index eb560a484..dbfe48e17 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -86,6 +86,8 @@ class Thelia extends Kernel $serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance()); $con->useDebug(true); } + + } /** diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index cf1d35195..c3ed552c0 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -32,6 +32,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Session; +use Thelia\Core\Event\CurrencyEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model; /** @@ -146,6 +148,9 @@ class TheliaHttpKernel extends HttpKernel $currency = null; if ($request->query->has("currency")) { $currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency")); + if($currency) { + $this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyEvent($currency)); + } } else { $currency = $request->getSession()->getCurrency(false); } @@ -212,7 +217,7 @@ class TheliaHttpKernel extends HttpKernel if (Model\ConfigQuery::read("session_config.default")) { $storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/'))); } else { - $handlerString = Model\ConfigQuery::read("session_config.handlers"); + $handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler'); $handler = new $handlerString; diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index 134d061be..b2c168186 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -155,4 +155,18 @@ interface CouponAdapterInterface */ public function getMainCurrency(); + /** + * Return request + * + * @return Request + */ + public function getRequest(); + + /** + * Return Constraint Validator + * + * @return ConstraintValidator + */ + public function getConstraintValidator(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index 3e77a56be..046b4ac81 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -27,9 +27,14 @@ use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Constraint\ConstraintValidator; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Security\SecurityContext; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; +use Thelia\Cart\CartTrait; +use Thelia\Model\Currency; /** * Created by JetBrains PhpStorm. @@ -43,6 +48,10 @@ use Thelia\Model\CouponQuery; */ class CouponBaseAdapter implements CouponAdapterInterface { + use CartTrait { + CartTrait::getCart as getCartFromTrait; + } + /** @var ContainerInterface Service Container */ protected $container = null; @@ -66,7 +75,7 @@ class CouponBaseAdapter implements CouponAdapterInterface */ public function getCart() { - // TODO: Implement getCart() method. + return $this->getCartFromTrait($this->getRequest()); } /** @@ -86,7 +95,7 @@ class CouponBaseAdapter implements CouponAdapterInterface */ public function getCustomer() { - // TODO: Implement getCustomer() method. + return $this->container->get('thelia.securityContext')->getCustomerUser(); } /** @@ -122,11 +131,11 @@ class CouponBaseAdapter implements CouponAdapterInterface /** * Return the Checkout currency EUR|USD * - * @return string + * @return Currency */ public function getCheckoutCurrency() { - // TODO: Implement getCheckoutCurrency() method. + $this->getRequest()->getSession()->getCurrency(); } @@ -147,9 +156,14 @@ class CouponBaseAdapter implements CouponAdapterInterface */ public function getCurrentCoupons() { + // @todo implement +// $consumedCoupons = $this->getRequest()->getSession()->getConsumedCoupons(); + // @todo convert coupon code to coupon Interface + + $couponFactory = $this->container->get('thelia.coupon.factory'); - // @todo Get from Session + // @todo get from cart $couponCodes = array('XMAS', 'SPRINGBREAK'); $coupons = array(); @@ -208,7 +222,7 @@ class CouponBaseAdapter implements CouponAdapterInterface */ public function getContainer() { - // TODO: Implement getContainer() method. + return $this->container; } /** @@ -232,4 +246,34 @@ class CouponBaseAdapter implements CouponAdapterInterface { // TODO: Implement getMainCurrency() method. } + + /** + * Return request + * + * @return Request + */ + public function getRequest() + { + return $this->container->get('request'); + } + + /** + * Return Constraint Validator + * + * @return ConstraintValidator + */ + public function getConstraintValidator() + { + return $this->container->get('thelia.constraint.validator'); + } + + /** + * Return the event dispatcher, + * + * @return \Symfony\Component\EventDispatcher\EventDispatcher + */ + public function getDispatcher() + { + return $this->container->get('event_dispatcher'); + } } diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 93cdd21fe..d8575c3e6 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -183,6 +183,7 @@ class CouponManager $discount = 0.00; /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { + // @todo modify Cart with discount for each cart item $discount += $coupon->getDiscount($this->adapter); } diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index 647635024..45e1427f1 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -26,6 +26,7 @@ namespace Thelia\Coupon\Type; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Constraint\ConstraintManager; use Thelia\Constraint\ConstraintValidator; +use Thelia\Core\Translation\Translator; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\CouponRuleCollection; use Thelia\Coupon\RuleOrganizerInterface; @@ -44,9 +45,6 @@ use Thelia\Exception\InvalidRuleException; */ abstract class CouponAbstract implements CouponInterface { - /** @var string Service Id */ - protected $serviceId = null; - /** @var CouponAdapterInterface Provide necessary value from Thelia */ protected $adapter = null; @@ -62,9 +60,19 @@ abstract class CouponAbstract implements CouponInterface /** @var ConstraintValidator Constraint validator */ protected $constraintValidator = null; + + + /** @var string Service Id */ + protected $serviceId = null; + + /** @var float Amount that will be removed from the Checkout (Coupon Effect) */ + protected $amount = 0; + /** @var string Coupon code (ex: XMAS) */ protected $code = null; + + /** @var string Coupon title (ex: Coupon for XMAS) */ protected $title = null; @@ -74,6 +82,8 @@ abstract class CouponAbstract implements CouponInterface /** @var string Coupon description */ protected $description = null; + + /** @var bool if Coupon is enabled */ protected $isEnabled = false; @@ -86,9 +96,6 @@ abstract class CouponAbstract implements CouponInterface /** @var bool if Coupon is removing postage */ protected $isRemovingPostage = false; - /** @var float Amount that will be removed from the Checkout (Coupon Effect) */ - protected $amount = 0; - /** @var int Max time a Coupon can be used (-1 = unlimited) */ protected $maxUsage = -1; @@ -105,6 +112,7 @@ abstract class CouponAbstract implements CouponInterface { $this->adapter = $adapter; $this->translator = $adapter->getTranslator(); + $this->constraintValidator = $adapter->getConstraintValidator(); } /** @@ -220,17 +228,6 @@ abstract class CouponAbstract implements CouponInterface return $this; } - /** - * Check if the current Coupon is matching its conditions (Rules) - * Thelia variables are given by the CouponAdapterInterface - * - * @return bool - */ - public function isMatching() - { - return $this->constraintValidator->test($this->rules); - } - /** * Return Coupon expiration date * @@ -302,4 +299,16 @@ abstract class CouponAbstract implements CouponInterface } + /** + * Check if the current Coupon is matching its conditions (Rules) + * Thelia variables are given by the CouponAdapterInterface + * + * @return bool + */ + public function isMatching() + { + return $this->constraintValidator->isMatching($this->rules); + } + + } diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index f0426298f..be76c1878 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -39,6 +39,27 @@ use Thelia\Coupon\CouponRuleCollection; */ interface CouponInterface { + /** + * Get I18n name + * + * @return string + */ + public function getName(); + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip(); + + /** + * Get Coupon Manager service Id + * + * @return string + */ + public function getServiceId(); + /** * Set Coupon * @@ -114,18 +135,7 @@ interface CouponInterface */ public function isRemovingPostage(); - /** - * Return effects generated by the coupon - * A positive value - * - * Effects could also affect something else than the final Checkout price - * CouponAdapter $adapter could be use to directly pass a Session value - * some would wish to modify - * Hence affecting a wide variety of Thelia elements - * - * @return float Amount removed from the Total Checkout - */ - public function getDiscount(); + /** * Return condition to validate the Coupon or not @@ -134,14 +144,6 @@ interface CouponInterface */ public function getRules(); - /** - * Check if the current Coupon is matching its conditions (Rules) - * Thelia variables are given by the CouponAdapterInterface - * - * @return bool - */ - public function isMatching(); - /** * Replace the existing Rules by those given in parameter * If one Rule is badly implemented, no Rule will be added @@ -191,25 +193,26 @@ interface CouponInterface */ public function isExpired(); - /** - * Get I18n name - * - * @return string - */ - public function getName(); /** - * Get I18n tooltip + * Return effects generated by the coupon + * A positive value * - * @return string + * Effects could also affect something else than the final Checkout price + * CouponAdapter $adapter could be use to directly pass a Session value + * some would wish to modify + * Hence affecting a wide variety of Thelia elements + * + * @return float Amount removed from the Total Checkout */ - public function getToolTip(); + public function getDiscount(); /** - * Get Coupon Manager service Id + * Check if the current Coupon is matching its conditions (Rules) + * Thelia variables are given by the CouponAdapterInterface * - * @return string + * @return bool */ - public function getServiceId(); + public function isMatching(); } diff --git a/core/lib/Thelia/Exception/DocumentException.php b/core/lib/Thelia/Exception/DocumentException.php new file mode 100644 index 000000000..9727a4267 --- /dev/null +++ b/core/lib/Thelia/Exception/DocumentException.php @@ -0,0 +1,36 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +class DocumentException extends \RuntimeException +{ + public function __construct($message, $code = null, $previous = null) + { + Tlog::getInstance()->addError($message); + + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Exception/ModuleException.php b/core/lib/Thelia/Exception/ModuleException.php new file mode 100755 index 000000000..263a071b0 --- /dev/null +++ b/core/lib/Thelia/Exception/ModuleException.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +class ModuleException extends \RuntimeException +{ + const UNKNOWN_EXCEPTION = 0; + + const CODE_NOT_FOUND = 404; + + public function __construct($message, $code = null, $previous = null) + { + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php new file mode 100755 index 000000000..70fd21c01 --- /dev/null +++ b/core/lib/Thelia/Exception/OrderException.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +class OrderException extends \RuntimeException +{ + /** + * @var string The cart template name + */ + public $cartRoute = "cart.view"; + public $orderDeliveryRoute = "order.delivery"; + + public $arguments = array(); + + const UNKNOWN_EXCEPTION = 0; + + const CART_EMPTY = 100; + + const UNDEFINED_DELIVERY = 200; + + public function __construct($message, $code = null, $arguments = array(), $previous = null) + { + if(is_array($arguments)) { + $this->arguments = $arguments; + } + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Exception/TaxEngineException.php b/core/lib/Thelia/Exception/TaxEngineException.php index 93f5b8237..86f8952b9 100755 --- a/core/lib/Thelia/Exception/TaxEngineException.php +++ b/core/lib/Thelia/Exception/TaxEngineException.php @@ -39,6 +39,7 @@ class TaxEngineException extends \RuntimeException const UNDEFINED_TAX_RULES_COLLECTION = 503; const UNDEFINED_REQUIREMENTS = 504; const UNDEFINED_REQUIREMENT_VALUE = 505; + const UNDEFINED_TAX_RULE = 506; const BAD_AMOUNT_FORMAT = 601; diff --git a/core/lib/Thelia/Exception/TheliaProcessException.php b/core/lib/Thelia/Exception/TheliaProcessException.php new file mode 100755 index 000000000..f61224dea --- /dev/null +++ b/core/lib/Thelia/Exception/TheliaProcessException.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +/** + * these exception are non fatal exception, due to thelia process exception + * or customer random navigation + * + * they redirect the customer who trig them to a specific error page // @todo + * + * Class TheliaProcessException + * @package Thelia\Exception + */ +class TheliaProcessException extends \RuntimeException +{ + public $data = null; + + const UNKNOWN_EXCEPTION = 0; + + const CART_ITEM_NOT_ENOUGH_STOCK = 100; + const NO_PLACED_ORDER = 101; + const PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER = 102; + + public function __construct($message, $code = null, $data = null, $previous = null) + { + $this->data = $data; + + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 88b9964e4..00236161d 100755 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -24,6 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; class AdminLogin extends BaseForm { @@ -34,15 +35,27 @@ class AdminLogin extends BaseForm "constraints" => array( new NotBlank(), new Length(array("min" => 3)) + ), + "label" => Translator::getInstance()->trans("Username *"), + "label_attr" => array( + "for" => "username" ) )) ->add("password", "password", array( "constraints" => array( new NotBlank() + ), + "label" => Translator::getInstance()->trans("Password *"), + "label_attr" => array( + "for" => "password" ) )) ->add("remember_me", "checkbox", array( - 'value' => 'yes' + 'value' => 'yes', + "label" => Translator::getInstance()->trans("Remember me ?"), + "label_attr" => array( + "for" => "remember_me" + ) )) ; } diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php index 25bde3cdc..53496c513 100755 --- a/core/lib/Thelia/Form/CartAdd.php +++ b/core/lib/Thelia/Form/CartAdd.php @@ -29,6 +29,7 @@ use Thelia\Form\Exception\ProductNotFoundException; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ConfigQuery; use Thelia\Model\ProductQuery; +use Thelia\Core\Translation\Translator; /** * Class CartAdd @@ -75,13 +76,15 @@ class CartAdd extends BaseForm )) ->add("product_sale_elements_id", "text", array( "constraints" => array( + new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array( array($this, "checkStockAvailability") ))) - ) + ), + "required" => true )) - ->add("quantity", "text", array( + ->add("quantity", "number", array( "constraints" => array( new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array( @@ -90,6 +93,10 @@ class CartAdd extends BaseForm new Constraints\GreaterThanOrEqual(array( "value" => 0 )) + ), + "label" => Translator::getInstance()->trans("Quantity"), + "label_attr" => array( + "for" => "quantity" ) )) ->add("append", "hidden") @@ -126,13 +133,17 @@ class CartAdd extends BaseForm { $data = $context->getRoot()->getData(); - $productSaleElements = ProductSaleElementsQuery::create() - ->filterById($data["product_sale_elements_id"]) - ->filterByProductId($data["product"]) - ->findOne(); + if (null === $data["product_sale_elements_id"]) { + $context->addViolationAt("quantity", Translator::getInstance()->trans("Invalid product_sale_elements")); + } else { + $productSaleElements = ProductSaleElementsQuery::create() + ->filterById($data["product_sale_elements_id"]) + ->filterByProductId($data["product"]) + ->findOne(); - if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) { - $context->addViolation("quantity value is not valid"); + if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) { + $context->addViolation("quantity value is not valid"); + } } } diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 5dce6a049..6a0172180 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -39,15 +39,22 @@ class CategoryCreationForm extends BaseForm "for" => "title" ) )) - ->add("parent", "integer", array( + ->add("parent", "text", array( + "label" => Translator::getInstance()->trans("Parent category *"), "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "parent_create") )) ->add("locale", "text", array( "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "locale_create") + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This category is online."), + "label_attr" => array("for" => "visible_create") )) ; } diff --git a/core/lib/Thelia/Form/CategoryModificationForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php index d9de36d16..943c0d941 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -24,6 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; class CategoryModificationForm extends CategoryCreationForm { @@ -36,12 +37,14 @@ class CategoryModificationForm extends CategoryCreationForm $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - ->add("visible", "checkbox", array( - "label" => Translator::getInstance()->trans("This category is online on the front office.") + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url") )) ; - // Add standard description fields + // Add standard description fields, excluding title and locale, which a re defined in parent class $this->addStandardDescFields(array('title', 'locale')); } diff --git a/core/lib/Thelia/Form/ContentCreationForm.php b/core/lib/Thelia/Form/ContentCreationForm.php new file mode 100644 index 000000000..df8838f59 --- /dev/null +++ b/core/lib/Thelia/Form/ContentCreationForm.php @@ -0,0 +1,65 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class ContentCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => "Content title *", + "label_attr" => array( + "for" => "title" + ) + )) + ->add("default_folder", "integer", array( + "label" => Translator::getInstance()->trans("Default folder *"), + "constraints" => array( + new NotBlank() + ), + "label_attr" => array("for" => "default_folder") + )) + ->add("locale", "text", array( + "constraints" => array( + new NotBlank() + ) + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This content is online."), + "label_attr" => array("for" => "visible_create") + )) + ; + } + + public function getName() + { + return "thelia_content_creation"; + } +} diff --git a/core/lib/Thelia/Form/ContentModificationForm.php b/core/lib/Thelia/Form/ContentModificationForm.php new file mode 100644 index 000000000..38ad4e2cf --- /dev/null +++ b/core/lib/Thelia/Form/ContentModificationForm.php @@ -0,0 +1,61 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\Form\StandardDescriptionFieldsTrait; + +/** + * Class ContentModificationForm + * @package Thelia\Form + * @author manuel raynaud + */ +class ContentModificationForm extends ContentCreationForm { + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewritten_url") + )) + ; + + // Add standard description fields, excluding title and locale, which a re defined in parent class + $this->addStandardDescFields(array('title', 'locale')); + } + + public function getName() + { + return "thelia_content_modification"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/CountryCreationForm.php b/core/lib/Thelia/Form/CountryCreationForm.php new file mode 100644 index 000000000..ad6701a64 --- /dev/null +++ b/core/lib/Thelia/Form/CountryCreationForm.php @@ -0,0 +1,85 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class CountryCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country title *"), + "label_attr" => array( + "for" => "title" + ) + )) + ->add("area", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country area *"), + "label_attr" => array( + "for" => "area" + ) + )) + ->add("isocode", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("ISO Code *"), + "label_attr" => array( + "for" => "isocode" + ) + )) + ->add("isoalpha2", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 2 *"), + "label_attr" => array( + "for" => "isoalpha2" + ) + )) + ->add("isoalpha3", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 3 *"), + "label_attr" => array( + "for" => "isoalpha3" + ) + )) + ; + } + + public function getName() + { + return "thelia_country_creation"; + } +} diff --git a/core/lib/Thelia/Form/CountryModificationForm.php b/core/lib/Thelia/Form/CountryModificationForm.php new file mode 100644 index 000000000..4c1581664 --- /dev/null +++ b/core/lib/Thelia/Form/CountryModificationForm.php @@ -0,0 +1,107 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class CountryModificationForm extends CurrencyCreationForm +{ + protected function buildForm() + { + parent::buildForm(true); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country title *"), + "label_attr" => array( + "for" => "title" + ) + )) + ->add("short-description", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country short description *"), + "label_attr" => array( + "for" => "short-description" + ) + )) + ->add("description", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country description *"), + "label_attr" => array( + "for" => "description" + ) + )) + ->add("area", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country area *"), + "label_attr" => array( + "for" => "area" + ) + )) + ->add("isocode", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("ISO Code *"), + "label_attr" => array( + "for" => "isocode" + ) + )) + ->add("isoalpha2", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 2 *"), + "label_attr" => array( + "for" => "isoalpha2" + ) + )) + ->add("isoalpha3", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 3 *"), + "label_attr" => array( + "for" => "isoalpha3" + ) + )) + ; + } + + public function getName() + { + return "thelia_country_modification"; + } +} diff --git a/core/lib/Thelia/Form/CouponCreationForm.php b/core/lib/Thelia/Form/CouponCreationForm.php index d63a4284d..1625ab685 100755 --- a/core/lib/Thelia/Form/CouponCreationForm.php +++ b/core/lib/Thelia/Form/CouponCreationForm.php @@ -23,7 +23,11 @@ namespace Thelia\Form; +use Symfony\Component\Validator\Constraints\Date; +use Symfony\Component\Validator\Constraints\DateTime; +use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints\NotEqualTo; /** * Created by JetBrains PhpStorm. @@ -68,7 +72,6 @@ class CouponCreationForm extends BaseForm 'shortDescription', 'text', array( - 'invalid_message' => 'test', 'constraints' => array( new NotBlank() ) @@ -78,7 +81,6 @@ class CouponCreationForm extends BaseForm 'description', 'textarea', array( - 'invalid_message' => 'test', 'constraints' => array( new NotBlank() ) @@ -88,16 +90,23 @@ class CouponCreationForm extends BaseForm 'effect', 'text', array( - 'invalid_message' => 'test', 'constraints' => array( - new NotBlank() + new NotBlank(), + new NotEqualTo( + array( + 'value' => -1 + ) + ) ) ) ) ->add( 'amount', 'money', - array() + array( + 'constraints' => array( + new NotBlank() + )) ) ->add( 'isEnabled', @@ -109,7 +118,8 @@ class CouponCreationForm extends BaseForm 'text', array( 'constraints' => array( - new NotBlank() + new NotBlank(), + new Date() ) ) ) @@ -133,7 +143,12 @@ class CouponCreationForm extends BaseForm 'text', array( 'constraints' => array( - new NotBlank() + new NotBlank(), + new GreaterThanOrEqual( + array( + 'value' => -1 + ) + ) ) ) ) diff --git a/core/lib/Thelia/Form/FeatureAvCreationForm.php b/core/lib/Thelia/Form/FeatureAvCreationForm.php new file mode 100644 index 000000000..504cc9338 --- /dev/null +++ b/core/lib/Thelia/Form/FeatureAvCreationForm.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class FeatureAvCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title" , "text" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Title *"), + "label_attr" => array( + "for" => "title" + )) + ) + ->add("locale" , "text" , array( + "constraints" => array( + new NotBlank() + )) + ) + ->add("feature_id", "hidden", array( + "constraints" => array( + new NotBlank() + )) + ) + ; + } + + public function getName() + { + return "thelia_featureav_creation"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/FeatureCreationForm.php b/core/lib/Thelia/Form/FeatureCreationForm.php new file mode 100644 index 000000000..1977bd78b --- /dev/null +++ b/core/lib/Thelia/Form/FeatureCreationForm.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class FeatureCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title" , "text" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Title *"), + "label_attr" => array( + "for" => "title" + )) + ) + ->add("locale" , "text" , array( + "constraints" => array( + new NotBlank() + )) + ) + ->add("add_to_all" , "checkbox" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Add to all product templates"), + "label_attr" => array( + "for" => "add_to_all" + )) + ) + ; + } + + public function getName() + { + return "thelia_feature_creation"; + } +} diff --git a/core/lib/Thelia/Form/FeatureModificationForm.php b/core/lib/Thelia/Form/FeatureModificationForm.php new file mode 100644 index 000000000..1702f299e --- /dev/null +++ b/core/lib/Thelia/Form/FeatureModificationForm.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\GreaterThan; + +class FeatureModificationForm extends FeatureCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + $this->formBuilder + ->add("id", "hidden", array( + "constraints" => array( + new GreaterThan( + array('value' => 0) + ) + ) + )) +/* FIXME: doesn't work + ->add('feature_values', 'collection', array( + 'type' => 'text', + 'options' => array('required' => false) + )) +*/ + ; + + // Add standard description fields + $this->addStandardDescFields(); + } + + public function getName() + { + return "thelia_feature_modification"; + } +} diff --git a/core/lib/Thelia/Form/FolderCreationForm.php b/core/lib/Thelia/Form/FolderCreationForm.php new file mode 100644 index 000000000..ac7b10376 --- /dev/null +++ b/core/lib/Thelia/Form/FolderCreationForm.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class FolderCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Folder title *"), + "label_attr" => array( + "for" => "title" + ) + )) + ->add("parent", "text", array( + "label" => Translator::getInstance()->trans("Parent folder *"), + "constraints" => array( + new NotBlank() + ), + "label_attr" => array("for" => "parent_create") + )) + ->add("locale", "text", array( + "constraints" => array( + new NotBlank() + ), + "label_attr" => array("for" => "locale_create") + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This folder is online."), + "label_attr" => array("for" => "visible_create") + )) + ; + } + + public function getName() + { + return "thelia_folder_creation"; + } +} diff --git a/core/lib/Thelia/Form/FolderModificationForm.php b/core/lib/Thelia/Form/FolderModificationForm.php new file mode 100644 index 000000000..0ff90868c --- /dev/null +++ b/core/lib/Thelia/Form/FolderModificationForm.php @@ -0,0 +1,55 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; + +class FolderModificationForm extends FolderCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url") + )) + ; + + // Add standard description fields, excluding title and locale, which a re defined in parent class + $this->addStandardDescFields(array('title', 'locale')); + } + + public function getName() + { + return "thelia_folder_modification"; + } +} diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php b/core/lib/Thelia/Form/InstallStep3Form.php old mode 100644 new mode 100755 similarity index 53% rename from core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php rename to core/lib/Thelia/Form/InstallStep3Form.php index ab06953e5..9388f14db --- a/core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php +++ b/core/lib/Thelia/Form/InstallStep3Form.php @@ -21,83 +21,91 @@ /* */ /**********************************************************************************/ -namespace Thelia\Core\Event\Coupon; -use Thelia\Model\Coupon; +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; /** * Created by JetBrains PhpStorm. * Date: 8/29/13 * Time: 3:45 PM * - * Occurring when a Coupon is enabled + * Allow to build a form Install Step 3 Database connection * * @package Coupon * @author Guillaume MOREL * */ -class CouponEnableEvent extends ActionEvent +class InstallStep3Form extends BaseForm { - /** @var int Coupon id */ - protected $couponId; - - /** @var Coupon Coupon being enabled */ - protected $enabledCoupon; - /** - * Constructor + * Build Coupon form * - * @param int $id Coupon Id + * @return void */ - public function __construct($id) + protected function buildForm() { - $this->id = $id; + $this->formBuilder + ->add( + 'host', + 'text', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ) + ->add( + 'user', + 'text', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ) + ->add( + 'password', + 'text', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ) + ->add( + 'port', + 'text', + array( + 'constraints' => array( + new NotBlank(), + new GreaterThan( + array( + 'value' => 0 + ) + ) + ) + ) + ) + ->add( + 'locale', + 'hidden', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ); } /** - * Get Coupon id + * Get form name * - * @return int + * @return string */ - public function getId() + public function getName() { - return $this->id; - } - - /** - * Set Coupon id - * - * @param int $id Coupon id - * - * @return $this - */ - public function setId($id) - { - $this->id = $id; - - return $this; - } - - /** - * Get Coupon being enabled - * - * @return Coupon - */ - public function getEnabledCoupon() - { - return $this->enabledCoupon; - } - - /** - * Set Coupon to be enabled - * - * @param Coupon $enabledCoupon Coupon to enabled - * - * @return $this - */ - public function setEnabledCoupon(Coupon $enabledCoupon) - { - $this->enabledCoupon = $enabledCoupon; - - return $this; + return 'thelia_install_step3'; } } diff --git a/core/lib/Thelia/Form/OrderDelivery.php b/core/lib/Thelia/Form/OrderDelivery.php new file mode 100755 index 000000000..8cddb5bd9 --- /dev/null +++ b/core/lib/Thelia/Form/OrderDelivery.php @@ -0,0 +1,101 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\AddressQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; + +/** + * Class OrderDelivery + * @package Thelia\Form + * @author Etienne Roudeix + */ +class OrderDelivery extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("delivery-address", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyDeliveryAddress") + ) + )) + ) + )) + ->add("delivery-module", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyDeliveryModule") + ) + )) + ) + )); + } + + public function verifyDeliveryAddress($value, ExecutionContextInterface $context) + { + $address = AddressQuery::create() + ->findPk($value); + + if(null === $address) { + $context->addViolation("Address ID not found"); + } + } + + public function verifyDeliveryModule($value, ExecutionContextInterface $context) + { + $module = ModuleQuery::create() + ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) + ->filterByActivate(1) + ->filterById($value) + ->findOne(); + + if(null === $module) { + $context->addViolation("Delivery module ID not found"); + } + + $moduleReflection = new \ReflectionClass($module->getFullNamespace()); + if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) { + $context->addViolation( + sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $module->getCode()) + ); + } + } + + public function getName() + { + return "thelia_order_delivery"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/OrderPayment.php b/core/lib/Thelia/Form/OrderPayment.php new file mode 100755 index 000000000..6a6305971 --- /dev/null +++ b/core/lib/Thelia/Form/OrderPayment.php @@ -0,0 +1,101 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\AddressQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; + +/** + * Class OrderPayment + * @package Thelia\Form + * @author Etienne Roudeix + */ +class OrderPayment extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("invoice-address", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyInvoiceAddress") + ) + )) + ) + )) + ->add("payment-module", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyPaymentModule") + ) + )) + ) + )); + } + + public function verifyInvoiceAddress($value, ExecutionContextInterface $context) + { + $address = AddressQuery::create() + ->findPk($value); + + if(null === $address) { + $context->addViolation("Address ID not found"); + } + } + + public function verifyPaymentModule($value, ExecutionContextInterface $context) + { + $module = ModuleQuery::create() + ->filterByType(BaseModule::PAYMENT_MODULE_TYPE) + ->filterByActivate(1) + ->filterById($value) + ->findOne(); + + if(null === $module) { + $context->addViolation("Payment module ID not found"); + } + + $moduleReflection = new \ReflectionClass($module->getFullNamespace()); + if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) { + $context->addViolation( + sprintf("delivery module %s is not a Thelia\Module\PaymentModuleInterface", $module->getCode()) + ); + } + } + + public function getName() + { + return "thelia_order_payment"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index 396f6d0d5..9329ca2ec 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -23,43 +23,64 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ProductQuery; +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\ExecutionContextInterface; class ProductCreationForm extends BaseForm { - protected function buildForm() + protected function buildForm($change_mode = false) { + $ref_constraints = array(new NotBlank()); + + if (! $change_mode) { + $ref_constraints[] = new Callback(array( + "methods" => array(array($this, "checkDuplicateRef")) + )); + } + $this->formBuilder ->add("ref", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => "Product reference *", - "label_attr" => array( - "for" => "ref" - ) + "constraints" => $ref_constraints, + "label" => "Product reference *", + "label_attr" => array("for" => "ref") )) ->add("title", "text", array( "constraints" => array( new NotBlank() ), "label" => "Product title *", - "label_attr" => array( - "for" => "title" - ) + "label_attr" => array("for" => "title") )) - ->add("parent", "integer", array( - "constraints" => array( - new NotBlank() - ) + ->add("default_category", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Default product category."), + "label_attr" => array("for" => "default_category_field") )) ->add("locale", "text", array( - "constraints" => array( - new NotBlank() - ) + "constraints" => array(new NotBlank()) + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This product is online."), + "label_attr" => array("for" => "visible_field") )) ; } + public function checkDuplicateRef($value, ExecutionContextInterface $context) + { + $count = ProductQuery::create()->filterByRef($value)->count(); + + if ($count > 0) { + $context->addViolation( + Translator::getInstance()->trans( + "A product with reference %ref already exists. Please choose another reference.", + array('%ref' => $value) + )); + } + } + public function getName() { return "thelia_product_creation"; diff --git a/core/lib/Thelia/Form/ProductModificationForm.php b/core/lib/Thelia/Form/ProductModificationForm.php new file mode 100644 index 000000000..dbda15eaa --- /dev/null +++ b/core/lib/Thelia/Form/ProductModificationForm.php @@ -0,0 +1,64 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; + +class ProductModificationForm extends ProductCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(true); + + $this->formBuilder + ->add("id", "integer", array( + "label" => Translator::getInstance()->trans("Prodcut ID *"), + "label_attr" => array("for" => "product_id_field"), + "constraints" => array(new GreaterThan(array('value' => 0))) + + )) + ->add("template_id", "integer", array( + "label" => Translator::getInstance()->trans("Product template"), + "label_attr" => array("for" => "product_template_field") + + )) + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url_field") + )) + ; + + // Add standard description fields, excluding title and locale, which a re defined in parent class + $this->addStandardDescFields(array('title', 'locale')); + } + + public function getName() + { + return "thelia_product_modification"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/ProfileModificationForm.php b/core/lib/Thelia/Form/ProfileModificationForm.php new file mode 100644 index 000000000..e3119cfee --- /dev/null +++ b/core/lib/Thelia/Form/ProfileModificationForm.php @@ -0,0 +1,119 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ConfigQuery; + +/** + * Class ProfileModification + * @package Thelia\Form + * @author Manuel Raynaud + */ +class ProfileModificationForm extends BaseForm +{ + + + protected function buildForm() + { + + $this->formBuilder + ->add("firstname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("First Name"), + "label_attr" => array( + "for" => "firstname" + ) + )) + ->add("lastname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Last Name"), + "label_attr" => array( + "for" => "lastname" + ) + )) + ->add("default_language", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Default language"), + "label_attr" => array( + "for" => "default_language" + ) + )) + ->add("editing_language_default", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Editing language default"), + "label_attr" => array( + "for" => "editing_language_default" + ) + )) + ->add("old_password", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ), + "label" => Translator::getInstance()->trans("Old password"), + "label_attr" => array( + "for" => "old_password" + ) + )) + ->add("password", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ), + "label" => Translator::getInstance()->trans("Password"), + "label_attr" => array( + "for" => "password" + ) + )) + ->add("password_confirm", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), + new Constraints\Callback(array("methods" => array( + array($this, "verifyPasswordField") + ))) + ), + "label" => "Password confirmation", + "label_attr" => array( + "for" => "password_confirmation" + ) + )) + ; + } + + public function getName() + { + return "thelia_profile_modification"; + } +} diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php index 9d1851252..b35aad12f 100644 --- a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -58,7 +58,8 @@ trait StandardDescriptionFieldsTrait "label" => Translator::getInstance()->trans("Title"), "label_attr" => array( "for" => "title" - ) + ), + "label_attr" => array("for" => "title_field") ) ); @@ -67,7 +68,7 @@ trait StandardDescriptionFieldsTrait ->add("chapo", "text", array( "label" => Translator::getInstance()->trans("Summary"), "label_attr" => array( - "for" => "summary" + "for" => "summary_field" ) )); @@ -76,7 +77,7 @@ trait StandardDescriptionFieldsTrait ->add("description", "text", array( "label" => Translator::getInstance()->trans("Detailed description"), "label_attr" => array( - "for" => "detailed_description" + "for" => "detailed_description_field" ) )); @@ -85,7 +86,7 @@ trait StandardDescriptionFieldsTrait ->add("postscriptum", "text", array( "label" => Translator::getInstance()->trans("Conclusion"), "label_attr" => array( - "for" => "conclusion" + "for" => "conclusion_field" ) )); } diff --git a/core/lib/Thelia/Form/TemplateCreationForm.php b/core/lib/Thelia/Form/TemplateCreationForm.php new file mode 100644 index 000000000..42e6db5a4 --- /dev/null +++ b/core/lib/Thelia/Form/TemplateCreationForm.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class TemplateCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("name" , "text" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Template Name *"), + "label_attr" => array( + "for" => "name" + )) + ) + ->add("locale" , "text" , array( + "constraints" => array( + new NotBlank() + )) + ) + ; + } + + public function getName() + { + return "thelia_template_creation"; + } +} diff --git a/core/lib/Thelia/Form/TemplateModificationForm.php b/core/lib/Thelia/Form/TemplateModificationForm.php new file mode 100644 index 000000000..b2b50a3ca --- /dev/null +++ b/core/lib/Thelia/Form/TemplateModificationForm.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\GreaterThan; + +class TemplateModificationForm extends TemplateCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->add("id", "hidden", array( + "constraints" => array( + new GreaterThan( + array('value' => 0) + ) + ) + )) +/* + ->add('attributes', 'collection', array( + 'type' => 'text', + 'options' => array('required' => false) + )) +*/ +/* FIXME: doesn't work + ->add('features', 'collection', array( + 'type' => 'text', + 'options' => array('required' => false) + )) +*/ + ; + } + + public function getName() + { + return "thelia_template_modification"; + } +} diff --git a/core/lib/Thelia/Install/BaseInstall.php b/core/lib/Thelia/Install/BaseInstall.php index 58c510267..aa41140dd 100644 --- a/core/lib/Thelia/Install/BaseInstall.php +++ b/core/lib/Thelia/Install/BaseInstall.php @@ -25,15 +25,30 @@ use Thelia\Install\Exception\AlreadyInstallException; /** * Class BaseInstall + * * @author Manuel Raynaud */ abstract class BaseInstall { + /** @var bool If Installation wizard is launched by CLI */ + protected $isConsoleMode = true; + /** - * Verify if an installation already exists + * Constructor + * + * @param bool $verifyInstall Verify if an installation already exists + * + * @throws Exception\AlreadyInstallException */ public function __construct($verifyInstall = true) { + + // Check if install wizard is launched via CLI + if (php_sapi_name() == 'cli') { + $this->isConsoleMode = true; + } else { + $this->isConsoleMode = false; + } if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) { throw new AlreadyInstallException("Thelia is already installed"); } diff --git a/core/lib/Thelia/Install/CheckDatabaseConnection.php b/core/lib/Thelia/Install/CheckDatabaseConnection.php new file mode 100644 index 000000000..c9c2060f5 --- /dev/null +++ b/core/lib/Thelia/Install/CheckDatabaseConnection.php @@ -0,0 +1,122 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Install; + +use PDO; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; +use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Core\Translation\Translator; +use Thelia\Install\Exception\InstallException; + + +/** + * Class CheckDatabaseConnection + * + * Take care of integration tests (database connection) + * + * @package Thelia\Install + * @author Manuel Raynaud + * @author Guillaume MOREL + */ +class CheckDatabaseConnection extends BaseInstall +{ + protected $validationMessages = array(); + + /** @var bool If permissions are OK */ + protected $isValid = true; + + /** @var TranslatorInterface Translator Service */ + protected $translator = null; + + /** @var string Database host information */ + protected $host = null; + + /** @var string Database user information */ + protected $user = null; + + /** @var string Database password information */ + protected $password = null; + + /** @var int Database port information */ + protected $port = null; + + /** + * @var \PDO instance + */ + protected $connection = null; + + /** + * Constructor + * + * @param string $host Database host information + * @param string $user Database user information + * @param string $password Database password information + * @param int $port Database port information + * @param bool $verifyInstall If verify install + * @param Translator $translator Translator Service + * necessary for install wizard + */ + public function __construct($host, $user, $password, $port, $verifyInstall = true, Translator $translator = null) + { + $this->host = $host; + $this->user = $user; + $this->password = $password; + $this->port = $port; + + parent::__construct($verifyInstall); + } + + /** + * Perform database connection check + * + * @return bool + */ + public function exec() + { + + $dsn = "mysql:host=%s;port=%s"; + + try { + $this->connection = new \PDO( + sprintf($dsn, $this->host, $this->port), + $this->user, + $this->password + ); + } catch (\PDOException $e) { + + $this->validationMessages = 'Wrong connection information'; + + $this->isValid = false; + } + + return $this->isValid; + } + + public function getConnection() + { + return $this->connection; + } + +} diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index db73330cf..15317211b 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -23,56 +23,366 @@ namespace Thelia\Install; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; +use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Core\Translation\Translator; + /** * Class CheckPermission + * + * Take care of integration tests (files permissions) + * * @package Thelia\Install - * @author Manuel Raynaud + * @author Manuel Raynaud + * @author Guillaume MOREL */ class CheckPermission extends BaseInstall { - const CONF = "const"; - const LOG = "log"; - const CACHE = "cache"; - private $directories = array(); - private $validation = array(); - private $valid = true; + const DIR_CONF = 'local/config'; + const DIR_LOG = 'log'; + const DIR_CACHE = 'cache'; + const DIR_WEB = 'web'; - public function __construct($verifyInstall = true) + /** @var array Directory needed to be writable */ + protected $directoriesToBeWritable = array( + self::DIR_CONF, + self::DIR_LOG, + self::DIR_CACHE, + self::DIR_WEB, + ); + + /** @var array Minimum server configuration necessary */ + protected $minServerConfigurationNecessary = array( + 'memory_limit' => 134217728, + 'post_max_size' => 20971520, + 'upload_max_filesize' => 2097152 + ); + + protected $validationMessages = array(); + + /** @var bool If permissions are OK */ + protected $isValid = true; + + /** @var TranslatorInterface Translator Service */ + protected $translator = null; + + /** + * Constructor + * + * @param bool $verifyInstall If verify install + * @param Translator $translator Translator Service + * necessary for install wizard + */ + public function __construct($verifyInstall = true, Translator $translator = null) { + $this->translator = $translator; - - $this->directories = array( - self::CONF => THELIA_ROOT . "local/config", - self::LOG => THELIA_ROOT . "log", - self::CACHE => THELIA_ROOT . "cache" + $this->validationMessages['php_version'] = array( + 'text' => $this->getI18nPhpVersionText('5.4', phpversion(), true), + 'hint' => $this->getI18nPhpVersionHint(), + 'status' => true ); - $this->validation = array( - self::CONF => array( - "text" => sprintf("config directory(%s)...", $this->directories[self::CONF]), - "status" => true - ), - self::LOG => array( - "text" => sprintf("cache directory(%s)...", $this->directories[self::LOG]), - "status" => true - ), - self::CACHE => array( - "text" => sprintf("log directory(%s)...", $this->directories[self::CACHE]), - "status" => true - ) - ); + foreach ($this->directoriesToBeWritable as $directory) { + $this->validationMessages[$directory] = array( + 'text' => '', + 'hint' => '', + 'status' => true + ); + } + foreach ($this->minServerConfigurationNecessary as $key => $value) { + $this->validationMessages[$key] = array( + 'text' => '', + 'hint' => $this->getI18nConfigHint(), + 'status' => true + ); + } + parent::__construct($verifyInstall); } + /** + * Perform file permission check + * + * @return bool + */ public function exec() { - foreach ($this->directories as $key => $directory) { - if(is_writable($directory) === false) { - $this->valid = false; - $this->validation[$key]["status"] = false; + if (version_compare(phpversion(), '5.4', '<')) { + $this->validationMessages['php_version'] = $this->getI18nPhpVersionText('5.4', phpversion(), false); + } + + foreach ($this->directoriesToBeWritable as $directory) { + $fullDirectory = THELIA_ROOT . $directory; + $this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, true); + if (is_writable($fullDirectory) === false) { + if (!$this->makeDirectoryWritable($fullDirectory)) { + $this->isValid = false; + $this->validationMessages[$directory]['status'] = false; + $this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false); + $this->validationMessages[$directory]['hint'] = $this->getI18nDirectoryHint($fullDirectory); + } } } + + foreach ($this->minServerConfigurationNecessary as $key => $value) { + $this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), true); + if (!$this->verifyServerMemoryValues($key, $value)) { + $this->isValid = false; + $this->validationMessages[$key]['status'] = false; + $this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), false);; + } + } + + + + + return $this->isValid; } -} \ No newline at end of file + + /** + * Get validation messages + * + * @return array + */ + public function getValidationMessages() + { + return $this->validationMessages; + } + + /** + * Make a directory writable (recursively) + * + * @param string $directory path to directory + * + * @return bool + */ + protected function makeDirectoryWritable($directory) + { + chmod($directory, 0777); + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($directory) + ); + foreach ($iterator as $item) { + chmod($item, 0777); + } + + return (is_writable(THELIA_ROOT . $directory) === true); + } + + + + /** + * Get Translated text about the directory state + * + * @param string $directory Directory being checked + * @param bool $isValid If directory permission is valid + * + * @return string + */ + protected function getI18nDirectoryText($directory, $isValid) + { + if ($this->translator !== null) { + if ($isValid) { + $sentence = 'Your directory %directory% is writable'; + } else { + $sentence = 'Your directory %directory% is not writable'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%directory%' => $directory + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('Your directory %s needs to be writable', $directory); + } + + return $translatedText; + } + + /** + * Get Translated hint about the directory state + * + * @param string $directory Directory being checked + * + * @return string + */ + protected function getI18nDirectoryHint($directory) + { + if ($this->translator !== null) { + $sentence = 'chmod 777 %directory% on your server with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array( + '%directory%' => $directory + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('chmod 777 %s on your server with admin rights could help', $directory); + } + + return $translatedText; + } + + + /** + * Get Translated text about the directory state + * Not usable with CLI + * + * @param string $key .ini file key + * @param string $expectedValue Expected server value + * @param string $currentValue Actual server value + * @param bool $isValid If server configuration is valid + * + * @return string + */ + protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid) + { + if ($isValid) { + $sentence = 'Your %key% server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)'; + } else { + $sentence = 'Your %key% server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%key%' => $key, + '%expectedValue%' => $expectedValue, + '%currentValue%' => $currentValue, + ), + 'install-wizard' + ); + + return $translatedText; + } + + /** + * Get Translated hint about the config requirement issue + * + * @return string + */ + protected function getI18nConfigHint() + { + $sentence = 'Modifying this value on your server php.ini file with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array(), + 'install-wizard' + ); + + return $translatedText; + } + + /** + * Get Translated hint about the PHP version requirement issue + * + * @param string $expectedValue + * @param string $currentValue + * @param bool $isValid + * + * @return string + */ + protected function getI18nPhpVersionText($expectedValue, $currentValue, $isValid) + { + if ($this->translator !== null) { + if ($isValid) { + $sentence = 'Your PHP version %currentValue% is well enough to run Thelia2 (%expectedValue% needed)'; + } else { + $sentence = 'Your PHP version %currentValue% is not sufficient enough to run Thelia2 (%expectedValue% needed)'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%expectedValue%' => $expectedValue, + '%currentValue%' => $currentValue, + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('Thelia needs at least PHP %s (%s currently)', $expectedValue, $currentValue); + } + + return $translatedText; + } + + /** + * Get Translated hint about the config requirement issue + * + * @return string + */ + protected function getI18nPhpVersionHint() + { + $sentence = 'Upgrading your version of PHP with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array(), + 'install-wizard' + ); + + return $translatedText; + } + + /** + * Check if a server memory value is met or not + * + * @param string $key .ini file key + * @param int $necessaryValueInBytes Expected value in bytes + * + * @return bool + */ + protected function verifyServerMemoryValues($key, $necessaryValueInBytes) + { + $serverValueInBytes = $this->returnBytes(ini_get($key)); + + return ($serverValueInBytes >= $necessaryValueInBytes); + } + + /** + * Return bytes from memory .ini value + * + * @param string $val .ini value + * + * @return int + */ + protected function returnBytes($val) + { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + switch($last) { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return $val; + } + + /** + * Convert bytes to readable string + * + * @param int $bytes bytes + * @param int $precision conversion precision + * + * @return string + */ + protected function formatBytes($bytes, $precision = 2) + { + $base = log($bytes) / log(1024); + $suffixes = array('', 'k', 'M', 'G', 'T'); + + return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; + } +} diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 34ca97dae..648a6431a 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -93,7 +93,7 @@ class Database */ public function createDatabase($dbName) { - $this->connection->query( + $this->connection->exec( sprintf( "CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8", $dbName diff --git a/core/lib/Thelia/Mailer/MailerFactory.php b/core/lib/Thelia/Mailer/MailerFactory.php new file mode 100644 index 000000000..a327a155f --- /dev/null +++ b/core/lib/Thelia/Mailer/MailerFactory.php @@ -0,0 +1,91 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Mailer; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Thelia\Core\Event\MailTransporterEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ConfigQuery; + + +/** + * Class MailerFactory + * @package Thelia\Mailer + * @author Manuel Raynaud + */ +class MailerFactory { + /** + * @var \Swift_Mailer + */ + protected $swiftMailer; + + protected $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher) + { + + $this->dispatcher = $dispatcher; + + $transporterEvent = new MailTransporterEvent(); + $this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent); + + if($transporterEvent->hasTransporter()) { + $transporter = $transporterEvent->getTransporter(); + } else { + if (ConfigQuery::read("smtp.enabled")) { + $transporter = $this->configureSmtp(); + } else { + $transporter = \Swift_MailTransport::newInstance(); + } + } + + $this->swiftMailer = new \Swift_Mailer($transporter); + } + + private function configureSmtp() + { + $smtpTransporter = new \Swift_SmtpTransport(); + $smtpTransporter->setHost(Configquery::read('smtp.host', 'localhost')) + ->setPort(ConfigQuery::read('smtp.host')) + ->setEncryption(ConfigQuery::read('smtp.encryption')) + ->setUsername(ConfigQuery::read('smtp.username')) + ->setPassword(ConfigQuery::read('smtp.password')) + ->setAuthMode(ConfigQuery::read('smtp.authmode')) + ->setTimeout(ConfigQuery::read('smtp.timeout', 30)) + ->setSourceIp(ConfigQuery::read('smtp.sourceip')) + ; + return $smtpTransporter; + } + + public function send(\Swift_Mime_Message $message, &$failedRecipients = null) + { + $this->swiftMailer->send($message, $failedRecipients); + } + + public function getSwiftMailer() + { + return $this->swiftMailer; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Accessory.php b/core/lib/Thelia/Model/Accessory.php index 2e927ff7c..f24aab680 100755 --- a/core/lib/Thelia/Model/Accessory.php +++ b/core/lib/Thelia/Model/Accessory.php @@ -3,7 +3,77 @@ namespace Thelia\Model; use Thelia\Model\Base\Accessory as BaseAccessory; +use Thelia\Core\Event\TheliaEvents; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\AccessoryEvent; class Accessory extends BaseAccessory { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our product + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProductId($this->getProductId()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEACCESSORY, new AccessoryEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEACCESSORY, new AccessoryEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEACCESSORY, new AccessoryEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEACCESSORY, new AccessoryEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEACCESSORY, new AccessoryEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEACCESSORY, new AccessoryEvent($this)); + } + } diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index a6deb7e60..2712eb95c 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -6,6 +6,7 @@ use Thelia\Core\Security\User\UserInterface; use Thelia\Core\Security\Role\Role; use Thelia\Model\Base\Admin as BaseAdmin; +use Propel\Runtime\Connection\ConnectionInterface; /** * Skeleton subclass for representing a row from the 'admin' table. @@ -20,11 +21,19 @@ use Thelia\Model\Base\Admin as BaseAdmin; */ class Admin extends BaseAdmin implements UserInterface { + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + // Set the serial number (for auto-login) + $this->setRememberMeSerial(uniqid()); + + return true; + } public function setPassword($password) { - \Thelia\Log\Tlog::getInstance()->debug($password); - if ($this->isNew() && ($password === null || trim($password) == "")) { throw new \InvalidArgumentException("customer password is mandatory on creation"); } @@ -65,4 +74,32 @@ class Admin extends BaseAdmin implements UserInterface public function getRoles() { return array(new Role('ADMIN')); } + + /** + * {@inheritDoc} + */ + public function getToken() { + return $this->getRememberMeToken(); + } + + /** + * {@inheritDoc} + */ + public function setToken($token) { + $this->setRememberMeToken($token)->save(); + } + + /** + * {@inheritDoc} + */ + public function getSerial() { + return $this->getRememberMeSerial(); + } + + /** + * {@inheritDoc} + */ + public function setSerial($serial) { + $this->setRememberMeSerial($serial)->save(); + } } diff --git a/core/lib/Thelia/Model/AreaDeliveryModule.php b/core/lib/Thelia/Model/AreaDeliveryModule.php new file mode 100644 index 000000000..206625a12 --- /dev/null +++ b/core/lib/Thelia/Model/AreaDeliveryModule.php @@ -0,0 +1,10 @@ +salt; } + /** + * Get the [remember_me_token] column value. + * + * @return string + */ + public function getRememberMeToken() + { + + return $this->remember_me_token; + } + + /** + * Get the [remember_me_serial] column value. + * + * @return string + */ + public function getRememberMeSerial() + { + + return $this->remember_me_serial; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -662,6 +696,48 @@ abstract class Admin implements ActiveRecordInterface return $this; } // setSalt() + /** + * Set the value of [remember_me_token] column. + * + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) + */ + public function setRememberMeToken($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->remember_me_token !== $v) { + $this->remember_me_token = $v; + $this->modifiedColumns[] = AdminTableMap::REMEMBER_ME_TOKEN; + } + + + return $this; + } // setRememberMeToken() + + /** + * Set the value of [remember_me_serial] column. + * + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) + */ + public function setRememberMeSerial($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->remember_me_serial !== $v) { + $this->remember_me_serial = $v; + $this->modifiedColumns[] = AdminTableMap::REMEMBER_ME_SERIAL; + } + + + return $this; + } // setRememberMeSerial() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -762,13 +838,19 @@ abstract class Admin implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)]; $this->salt = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('RememberMeToken', TableMap::TYPE_PHPNAME, $indexType)]; + $this->remember_me_token = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('RememberMeSerial', TableMap::TYPE_PHPNAME, $indexType)]; + $this->remember_me_serial = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -781,7 +863,7 @@ abstract class Admin implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = AdminTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 11; // 11 = AdminTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Admin object", 0, $e); @@ -1069,6 +1151,12 @@ abstract class Admin implements ActiveRecordInterface if ($this->isColumnModified(AdminTableMap::SALT)) { $modifiedColumns[':p' . $index++] = 'SALT'; } + if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_TOKEN)) { + $modifiedColumns[':p' . $index++] = 'REMEMBER_ME_TOKEN'; + } + if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_SERIAL)) { + $modifiedColumns[':p' . $index++] = 'REMEMBER_ME_SERIAL'; + } if ($this->isColumnModified(AdminTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1107,6 +1195,12 @@ abstract class Admin implements ActiveRecordInterface case 'SALT': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; + case 'REMEMBER_ME_TOKEN': + $stmt->bindValue($identifier, $this->remember_me_token, PDO::PARAM_STR); + break; + case 'REMEMBER_ME_SERIAL': + $stmt->bindValue($identifier, $this->remember_me_serial, PDO::PARAM_STR); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1197,9 +1291,15 @@ abstract class Admin implements ActiveRecordInterface return $this->getSalt(); break; case 7: - return $this->getCreatedAt(); + return $this->getRememberMeToken(); break; case 8: + return $this->getRememberMeSerial(); + break; + case 9: + return $this->getCreatedAt(); + break; + case 10: return $this->getUpdatedAt(); break; default: @@ -1238,8 +1338,10 @@ abstract class Admin implements ActiveRecordInterface $keys[4] => $this->getPassword(), $keys[5] => $this->getAlgo(), $keys[6] => $this->getSalt(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[7] => $this->getRememberMeToken(), + $keys[8] => $this->getRememberMeSerial(), + $keys[9] => $this->getCreatedAt(), + $keys[10] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1307,9 +1409,15 @@ abstract class Admin implements ActiveRecordInterface $this->setSalt($value); break; case 7: - $this->setCreatedAt($value); + $this->setRememberMeToken($value); break; case 8: + $this->setRememberMeSerial($value); + break; + case 9: + $this->setCreatedAt($value); + break; + case 10: $this->setUpdatedAt($value); break; } // switch() @@ -1343,8 +1451,10 @@ abstract class Admin implements ActiveRecordInterface if (array_key_exists($keys[4], $arr)) $this->setPassword($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setAlgo($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setSalt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[7], $arr)) $this->setRememberMeToken($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setRememberMeSerial($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]); } /** @@ -1363,6 +1473,8 @@ abstract class Admin implements ActiveRecordInterface if ($this->isColumnModified(AdminTableMap::PASSWORD)) $criteria->add(AdminTableMap::PASSWORD, $this->password); if ($this->isColumnModified(AdminTableMap::ALGO)) $criteria->add(AdminTableMap::ALGO, $this->algo); if ($this->isColumnModified(AdminTableMap::SALT)) $criteria->add(AdminTableMap::SALT, $this->salt); + if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_TOKEN)) $criteria->add(AdminTableMap::REMEMBER_ME_TOKEN, $this->remember_me_token); + if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_SERIAL)) $criteria->add(AdminTableMap::REMEMBER_ME_SERIAL, $this->remember_me_serial); if ($this->isColumnModified(AdminTableMap::CREATED_AT)) $criteria->add(AdminTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AdminTableMap::UPDATED_AT)) $criteria->add(AdminTableMap::UPDATED_AT, $this->updated_at); @@ -1434,6 +1546,8 @@ abstract class Admin implements ActiveRecordInterface $copyObj->setPassword($this->getPassword()); $copyObj->setAlgo($this->getAlgo()); $copyObj->setSalt($this->getSalt()); + $copyObj->setRememberMeToken($this->getRememberMeToken()); + $copyObj->setRememberMeSerial($this->getRememberMeSerial()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1935,6 +2049,8 @@ abstract class Admin implements ActiveRecordInterface $this->password = null; $this->algo = null; $this->salt = null; + $this->remember_me_token = null; + $this->remember_me_serial = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/AdminQuery.php b/core/lib/Thelia/Model/Base/AdminQuery.php index 1ac79b4fe..071832d9b 100644 --- a/core/lib/Thelia/Model/Base/AdminQuery.php +++ b/core/lib/Thelia/Model/Base/AdminQuery.php @@ -28,6 +28,8 @@ use Thelia\Model\Map\AdminTableMap; * @method ChildAdminQuery orderByPassword($order = Criteria::ASC) Order by the password column * @method ChildAdminQuery orderByAlgo($order = Criteria::ASC) Order by the algo column * @method ChildAdminQuery orderBySalt($order = Criteria::ASC) Order by the salt column + * @method ChildAdminQuery orderByRememberMeToken($order = Criteria::ASC) Order by the remember_me_token column + * @method ChildAdminQuery orderByRememberMeSerial($order = Criteria::ASC) Order by the remember_me_serial column * @method ChildAdminQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAdminQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -38,6 +40,8 @@ use Thelia\Model\Map\AdminTableMap; * @method ChildAdminQuery groupByPassword() Group by the password column * @method ChildAdminQuery groupByAlgo() Group by the algo column * @method ChildAdminQuery groupBySalt() Group by the salt column + * @method ChildAdminQuery groupByRememberMeToken() Group by the remember_me_token column + * @method ChildAdminQuery groupByRememberMeSerial() Group by the remember_me_serial column * @method ChildAdminQuery groupByCreatedAt() Group by the created_at column * @method ChildAdminQuery groupByUpdatedAt() Group by the updated_at column * @@ -59,6 +63,8 @@ use Thelia\Model\Map\AdminTableMap; * @method ChildAdmin findOneByPassword(string $password) Return the first ChildAdmin filtered by the password column * @method ChildAdmin findOneByAlgo(string $algo) Return the first ChildAdmin filtered by the algo column * @method ChildAdmin findOneBySalt(string $salt) Return the first ChildAdmin filtered by the salt column + * @method ChildAdmin findOneByRememberMeToken(string $remember_me_token) Return the first ChildAdmin filtered by the remember_me_token column + * @method ChildAdmin findOneByRememberMeSerial(string $remember_me_serial) Return the first ChildAdmin filtered by the remember_me_serial column * @method ChildAdmin findOneByCreatedAt(string $created_at) Return the first ChildAdmin filtered by the created_at column * @method ChildAdmin findOneByUpdatedAt(string $updated_at) Return the first ChildAdmin filtered by the updated_at column * @@ -69,6 +75,8 @@ use Thelia\Model\Map\AdminTableMap; * @method array findByPassword(string $password) Return ChildAdmin objects filtered by the password column * @method array findByAlgo(string $algo) Return ChildAdmin objects filtered by the algo column * @method array findBySalt(string $salt) Return ChildAdmin objects filtered by the salt column + * @method array findByRememberMeToken(string $remember_me_token) Return ChildAdmin objects filtered by the remember_me_token column + * @method array findByRememberMeSerial(string $remember_me_serial) Return ChildAdmin objects filtered by the remember_me_serial column * @method array findByCreatedAt(string $created_at) Return ChildAdmin objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAdmin objects filtered by the updated_at column * @@ -159,7 +167,7 @@ abstract class AdminQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, FIRSTNAME, LASTNAME, LOGIN, PASSWORD, ALGO, SALT, CREATED_AT, UPDATED_AT FROM admin WHERE ID = :p0'; + $sql = 'SELECT ID, FIRSTNAME, LASTNAME, LOGIN, PASSWORD, ALGO, SALT, REMEMBER_ME_TOKEN, REMEMBER_ME_SERIAL, CREATED_AT, UPDATED_AT FROM admin WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -463,6 +471,64 @@ abstract class AdminQuery extends ModelCriteria return $this->addUsingAlias(AdminTableMap::SALT, $salt, $comparison); } + /** + * Filter the query on the remember_me_token column + * + * Example usage: + * + * $query->filterByRememberMeToken('fooValue'); // WHERE remember_me_token = 'fooValue' + * $query->filterByRememberMeToken('%fooValue%'); // WHERE remember_me_token LIKE '%fooValue%' + * + * + * @param string $rememberMeToken The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminQuery The current query, for fluid interface + */ + public function filterByRememberMeToken($rememberMeToken = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($rememberMeToken)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $rememberMeToken)) { + $rememberMeToken = str_replace('*', '%', $rememberMeToken); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AdminTableMap::REMEMBER_ME_TOKEN, $rememberMeToken, $comparison); + } + + /** + * Filter the query on the remember_me_serial column + * + * Example usage: + * + * $query->filterByRememberMeSerial('fooValue'); // WHERE remember_me_serial = 'fooValue' + * $query->filterByRememberMeSerial('%fooValue%'); // WHERE remember_me_serial LIKE '%fooValue%' + * + * + * @param string $rememberMeSerial The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminQuery The current query, for fluid interface + */ + public function filterByRememberMeSerial($rememberMeSerial = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($rememberMeSerial)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $rememberMeSerial)) { + $rememberMeSerial = str_replace('*', '%', $rememberMeSerial); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AdminTableMap::REMEMBER_ME_SERIAL, $rememberMeSerial, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php index 08fc8be42..f561ba330 100644 --- a/core/lib/Thelia/Model/Base/Area.php +++ b/core/lib/Thelia/Model/Base/Area.php @@ -18,11 +18,11 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Area as ChildArea; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\AreaQuery as ChildAreaQuery; use Thelia\Model\Country as ChildCountry; use Thelia\Model\CountryQuery as ChildCountryQuery; -use Thelia\Model\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; use Thelia\Model\Map\AreaTableMap; abstract class Area implements ActiveRecordInterface @@ -72,10 +72,10 @@ abstract class Area implements ActiveRecordInterface protected $name; /** - * The value for the unit field. + * The value for the postage field. * @var double */ - protected $unit; + protected $postage; /** * The value for the created_at field. @@ -96,10 +96,10 @@ abstract class Area implements ActiveRecordInterface protected $collCountriesPartial; /** - * @var ObjectCollection|ChildDelivzone[] Collection to store aggregation of ChildDelivzone objects. + * @var ObjectCollection|ChildAreaDeliveryModule[] Collection to store aggregation of ChildAreaDeliveryModule objects. */ - protected $collDelivzones; - protected $collDelivzonesPartial; + protected $collAreaDeliveryModules; + protected $collAreaDeliveryModulesPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -119,7 +119,7 @@ abstract class Area implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $delivzonesScheduledForDeletion = null; + protected $areaDeliveryModulesScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\Area object. @@ -398,14 +398,14 @@ abstract class Area implements ActiveRecordInterface } /** - * Get the [unit] column value. + * Get the [postage] column value. * * @return double */ - public function getUnit() + public function getPostage() { - return $this->unit; + return $this->postage; } /** @@ -491,25 +491,25 @@ abstract class Area implements ActiveRecordInterface } // setName() /** - * Set the value of [unit] column. + * Set the value of [postage] column. * * @param double $v new value * @return \Thelia\Model\Area The current object (for fluent API support) */ - public function setUnit($v) + public function setPostage($v) { if ($v !== null) { $v = (double) $v; } - if ($this->unit !== $v) { - $this->unit = $v; - $this->modifiedColumns[] = AreaTableMap::UNIT; + if ($this->postage !== $v) { + $this->postage = $v; + $this->modifiedColumns[] = AreaTableMap::POSTAGE; } return $this; - } // setUnit() + } // setPostage() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -596,8 +596,8 @@ abstract class Area implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; $this->name = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Unit', TableMap::TYPE_PHPNAME, $indexType)]; - $this->unit = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postage = (null !== $col) ? (double) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -681,7 +681,7 @@ abstract class Area implements ActiveRecordInterface $this->collCountries = null; - $this->collDelivzones = null; + $this->collAreaDeliveryModules = null; } // if (deep) } @@ -834,18 +834,17 @@ abstract class Area implements ActiveRecordInterface } } - if ($this->delivzonesScheduledForDeletion !== null) { - if (!$this->delivzonesScheduledForDeletion->isEmpty()) { - foreach ($this->delivzonesScheduledForDeletion as $delivzone) { - // need to save related object because we set the relation to null - $delivzone->save($con); - } - $this->delivzonesScheduledForDeletion = null; + if ($this->areaDeliveryModulesScheduledForDeletion !== null) { + if (!$this->areaDeliveryModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AreaDeliveryModuleQuery::create() + ->filterByPrimaryKeys($this->areaDeliveryModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->areaDeliveryModulesScheduledForDeletion = null; } } - if ($this->collDelivzones !== null) { - foreach ($this->collDelivzones as $referrerFK) { + if ($this->collAreaDeliveryModules !== null) { + foreach ($this->collAreaDeliveryModules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -884,8 +883,8 @@ abstract class Area implements ActiveRecordInterface if ($this->isColumnModified(AreaTableMap::NAME)) { $modifiedColumns[':p' . $index++] = 'NAME'; } - if ($this->isColumnModified(AreaTableMap::UNIT)) { - $modifiedColumns[':p' . $index++] = 'UNIT'; + if ($this->isColumnModified(AreaTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; } if ($this->isColumnModified(AreaTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -910,8 +909,8 @@ abstract class Area implements ActiveRecordInterface case 'NAME': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case 'UNIT': - $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR); + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -988,7 +987,7 @@ abstract class Area implements ActiveRecordInterface return $this->getName(); break; case 2: - return $this->getUnit(); + return $this->getPostage(); break; case 3: return $this->getCreatedAt(); @@ -1027,7 +1026,7 @@ abstract class Area implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getName(), - $keys[2] => $this->getUnit(), + $keys[2] => $this->getPostage(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -1041,8 +1040,8 @@ abstract class Area implements ActiveRecordInterface if (null !== $this->collCountries) { $result['Countries'] = $this->collCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collDelivzones) { - $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAreaDeliveryModules) { + $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1085,7 +1084,7 @@ abstract class Area implements ActiveRecordInterface $this->setName($value); break; case 2: - $this->setUnit($value); + $this->setPostage($value); break; case 3: $this->setCreatedAt($value); @@ -1119,7 +1118,7 @@ abstract class Area implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setUnit($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setPostage($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -1135,7 +1134,7 @@ abstract class Area implements ActiveRecordInterface if ($this->isColumnModified(AreaTableMap::ID)) $criteria->add(AreaTableMap::ID, $this->id); if ($this->isColumnModified(AreaTableMap::NAME)) $criteria->add(AreaTableMap::NAME, $this->name); - if ($this->isColumnModified(AreaTableMap::UNIT)) $criteria->add(AreaTableMap::UNIT, $this->unit); + if ($this->isColumnModified(AreaTableMap::POSTAGE)) $criteria->add(AreaTableMap::POSTAGE, $this->postage); if ($this->isColumnModified(AreaTableMap::CREATED_AT)) $criteria->add(AreaTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AreaTableMap::UPDATED_AT)) $criteria->add(AreaTableMap::UPDATED_AT, $this->updated_at); @@ -1202,7 +1201,7 @@ abstract class Area implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setName($this->getName()); - $copyObj->setUnit($this->getUnit()); + $copyObj->setPostage($this->getPostage()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1217,9 +1216,9 @@ abstract class Area implements ActiveRecordInterface } } - foreach ($this->getDelivzones() as $relObj) { + foreach ($this->getAreaDeliveryModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDelivzone($relObj->copy($deepCopy)); + $copyObj->addAreaDeliveryModule($relObj->copy($deepCopy)); } } @@ -1267,8 +1266,8 @@ abstract class Area implements ActiveRecordInterface if ('Country' == $relationName) { return $this->initCountries(); } - if ('Delivzone' == $relationName) { - return $this->initDelivzones(); + if ('AreaDeliveryModule' == $relationName) { + return $this->initAreaDeliveryModules(); } } @@ -1491,31 +1490,31 @@ abstract class Area implements ActiveRecordInterface } /** - * Clears out the collDelivzones collection + * Clears out the collAreaDeliveryModules collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addDelivzones() + * @see addAreaDeliveryModules() */ - public function clearDelivzones() + public function clearAreaDeliveryModules() { - $this->collDelivzones = null; // important to set this to NULL since that means it is uninitialized + $this->collAreaDeliveryModules = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collDelivzones collection loaded partially. + * Reset is the collAreaDeliveryModules collection loaded partially. */ - public function resetPartialDelivzones($v = true) + public function resetPartialAreaDeliveryModules($v = true) { - $this->collDelivzonesPartial = $v; + $this->collAreaDeliveryModulesPartial = $v; } /** - * Initializes the collDelivzones collection. + * Initializes the collAreaDeliveryModules collection. * - * By default this just sets the collDelivzones collection to an empty array (like clearcollDelivzones()); + * By default this just sets the collAreaDeliveryModules collection to an empty array (like clearcollAreaDeliveryModules()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1524,17 +1523,17 @@ abstract class Area implements ActiveRecordInterface * * @return void */ - public function initDelivzones($overrideExisting = true) + public function initAreaDeliveryModules($overrideExisting = true) { - if (null !== $this->collDelivzones && !$overrideExisting) { + if (null !== $this->collAreaDeliveryModules && !$overrideExisting) { return; } - $this->collDelivzones = new ObjectCollection(); - $this->collDelivzones->setModel('\Thelia\Model\Delivzone'); + $this->collAreaDeliveryModules = new ObjectCollection(); + $this->collAreaDeliveryModules->setModel('\Thelia\Model\AreaDeliveryModule'); } /** - * Gets an array of ChildDelivzone objects which contain a foreign key that references this object. + * Gets an array of ChildAreaDeliveryModule objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1544,109 +1543,109 @@ abstract class Area implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDelivzone[] List of ChildDelivzone objects + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects * @throws PropelException */ - public function getDelivzones($criteria = null, ConnectionInterface $con = null) + public function getAreaDeliveryModules($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { // return empty collection - $this->initDelivzones(); + $this->initAreaDeliveryModules(); } else { - $collDelivzones = ChildDelivzoneQuery::create(null, $criteria) + $collAreaDeliveryModules = ChildAreaDeliveryModuleQuery::create(null, $criteria) ->filterByArea($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collDelivzonesPartial && count($collDelivzones)) { - $this->initDelivzones(false); + if (false !== $this->collAreaDeliveryModulesPartial && count($collAreaDeliveryModules)) { + $this->initAreaDeliveryModules(false); - foreach ($collDelivzones as $obj) { - if (false == $this->collDelivzones->contains($obj)) { - $this->collDelivzones->append($obj); + foreach ($collAreaDeliveryModules as $obj) { + if (false == $this->collAreaDeliveryModules->contains($obj)) { + $this->collAreaDeliveryModules->append($obj); } } - $this->collDelivzonesPartial = true; + $this->collAreaDeliveryModulesPartial = true; } - $collDelivzones->getInternalIterator()->rewind(); + $collAreaDeliveryModules->getInternalIterator()->rewind(); - return $collDelivzones; + return $collAreaDeliveryModules; } - if ($partial && $this->collDelivzones) { - foreach ($this->collDelivzones as $obj) { + if ($partial && $this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $obj) { if ($obj->isNew()) { - $collDelivzones[] = $obj; + $collAreaDeliveryModules[] = $obj; } } } - $this->collDelivzones = $collDelivzones; - $this->collDelivzonesPartial = false; + $this->collAreaDeliveryModules = $collAreaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; } } - return $this->collDelivzones; + return $this->collAreaDeliveryModules; } /** - * Sets a collection of Delivzone objects related by a one-to-many relationship + * Sets a collection of AreaDeliveryModule objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $delivzones A Propel collection. + * @param Collection $areaDeliveryModules A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildArea The current object (for fluent API support) */ - public function setDelivzones(Collection $delivzones, ConnectionInterface $con = null) + public function setAreaDeliveryModules(Collection $areaDeliveryModules, ConnectionInterface $con = null) { - $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); + $areaDeliveryModulesToDelete = $this->getAreaDeliveryModules(new Criteria(), $con)->diff($areaDeliveryModules); - $this->delivzonesScheduledForDeletion = $delivzonesToDelete; + $this->areaDeliveryModulesScheduledForDeletion = $areaDeliveryModulesToDelete; - foreach ($delivzonesToDelete as $delivzoneRemoved) { - $delivzoneRemoved->setArea(null); + foreach ($areaDeliveryModulesToDelete as $areaDeliveryModuleRemoved) { + $areaDeliveryModuleRemoved->setArea(null); } - $this->collDelivzones = null; - foreach ($delivzones as $delivzone) { - $this->addDelivzone($delivzone); + $this->collAreaDeliveryModules = null; + foreach ($areaDeliveryModules as $areaDeliveryModule) { + $this->addAreaDeliveryModule($areaDeliveryModule); } - $this->collDelivzones = $delivzones; - $this->collDelivzonesPartial = false; + $this->collAreaDeliveryModules = $areaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; return $this; } /** - * Returns the number of related Delivzone objects. + * Returns the number of related AreaDeliveryModule objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related Delivzone objects. + * @return int Count of related AreaDeliveryModule objects. * @throws PropelException */ - public function countDelivzones(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countAreaDeliveryModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { return 0; } if ($partial && !$criteria) { - return count($this->getDelivzones()); + return count($this->getAreaDeliveryModules()); } - $query = ChildDelivzoneQuery::create(null, $criteria); + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1656,58 +1655,83 @@ abstract class Area implements ActiveRecordInterface ->count($con); } - return count($this->collDelivzones); + return count($this->collAreaDeliveryModules); } /** - * Method called to associate a ChildDelivzone object to this object - * through the ChildDelivzone foreign key attribute. + * Method called to associate a ChildAreaDeliveryModule object to this object + * through the ChildAreaDeliveryModule foreign key attribute. * - * @param ChildDelivzone $l ChildDelivzone + * @param ChildAreaDeliveryModule $l ChildAreaDeliveryModule * @return \Thelia\Model\Area The current object (for fluent API support) */ - public function addDelivzone(ChildDelivzone $l) + public function addAreaDeliveryModule(ChildAreaDeliveryModule $l) { - if ($this->collDelivzones === null) { - $this->initDelivzones(); - $this->collDelivzonesPartial = true; + if ($this->collAreaDeliveryModules === null) { + $this->initAreaDeliveryModules(); + $this->collAreaDeliveryModulesPartial = true; } - if (!in_array($l, $this->collDelivzones->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDelivzone($l); + if (!in_array($l, $this->collAreaDeliveryModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAreaDeliveryModule($l); } return $this; } /** - * @param Delivzone $delivzone The delivzone object to add. + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to add. */ - protected function doAddDelivzone($delivzone) + protected function doAddAreaDeliveryModule($areaDeliveryModule) { - $this->collDelivzones[]= $delivzone; - $delivzone->setArea($this); + $this->collAreaDeliveryModules[]= $areaDeliveryModule; + $areaDeliveryModule->setArea($this); } /** - * @param Delivzone $delivzone The delivzone object to remove. + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to remove. * @return ChildArea The current object (for fluent API support) */ - public function removeDelivzone($delivzone) + public function removeAreaDeliveryModule($areaDeliveryModule) { - if ($this->getDelivzones()->contains($delivzone)) { - $this->collDelivzones->remove($this->collDelivzones->search($delivzone)); - if (null === $this->delivzonesScheduledForDeletion) { - $this->delivzonesScheduledForDeletion = clone $this->collDelivzones; - $this->delivzonesScheduledForDeletion->clear(); + if ($this->getAreaDeliveryModules()->contains($areaDeliveryModule)) { + $this->collAreaDeliveryModules->remove($this->collAreaDeliveryModules->search($areaDeliveryModule)); + if (null === $this->areaDeliveryModulesScheduledForDeletion) { + $this->areaDeliveryModulesScheduledForDeletion = clone $this->collAreaDeliveryModules; + $this->areaDeliveryModulesScheduledForDeletion->clear(); } - $this->delivzonesScheduledForDeletion[]= $delivzone; - $delivzone->setArea(null); + $this->areaDeliveryModulesScheduledForDeletion[]= clone $areaDeliveryModule; + $areaDeliveryModule->setArea(null); } return $this; } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Area is new, it will return + * an empty collection; or if this Area has previously + * been saved, it will retrieve related AreaDeliveryModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Area. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + */ + public function getAreaDeliveryModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + $query->joinWith('Module', $joinBehavior); + + return $this->getAreaDeliveryModules($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1715,7 +1739,7 @@ abstract class Area implements ActiveRecordInterface { $this->id = null; $this->name = null; - $this->unit = null; + $this->postage = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1742,8 +1766,8 @@ abstract class Area implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collDelivzones) { - foreach ($this->collDelivzones as $o) { + if ($this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $o) { $o->clearAllReferences($deep); } } @@ -1753,10 +1777,10 @@ abstract class Area implements ActiveRecordInterface $this->collCountries->clearIterator(); } $this->collCountries = null; - if ($this->collDelivzones instanceof Collection) { - $this->collDelivzones->clearIterator(); + if ($this->collAreaDeliveryModules instanceof Collection) { + $this->collAreaDeliveryModules->clearIterator(); } - $this->collDelivzones = null; + $this->collAreaDeliveryModules = null; } /** diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php similarity index 80% rename from core/lib/Thelia/Model/Base/Delivzone.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModule.php index deb21997e..38a16dd5a 100644 --- a/core/lib/Thelia/Model/Base/Delivzone.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php @@ -17,17 +17,19 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Area as ChildArea; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\AreaQuery as ChildAreaQuery; -use Thelia\Model\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; -use Thelia\Model\Map\DelivzoneTableMap; +use Thelia\Model\Module as ChildModule; +use Thelia\Model\ModuleQuery as ChildModuleQuery; +use Thelia\Model\Map\AreaDeliveryModuleTableMap; -abstract class Delivzone implements ActiveRecordInterface +abstract class AreaDeliveryModule implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\DelivzoneTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\AreaDeliveryModuleTableMap'; /** @@ -69,10 +71,10 @@ abstract class Delivzone implements ActiveRecordInterface protected $area_id; /** - * The value for the delivery field. - * @var string + * The value for the delivery_module_id field. + * @var int */ - protected $delivery; + protected $delivery_module_id; /** * The value for the created_at field. @@ -91,6 +93,11 @@ abstract class Delivzone implements ActiveRecordInterface */ protected $aArea; + /** + * @var Module + */ + protected $aModule; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -100,7 +107,7 @@ abstract class Delivzone implements ActiveRecordInterface protected $alreadyInSave = false; /** - * Initializes internal state of Thelia\Model\Base\Delivzone object. + * Initializes internal state of Thelia\Model\Base\AreaDeliveryModule object. */ public function __construct() { @@ -195,9 +202,9 @@ abstract class Delivzone implements ActiveRecordInterface } /** - * Compares this with another Delivzone instance. If - * obj is an instance of Delivzone, delegates to - * equals(Delivzone). Otherwise, returns false. + * Compares this with another AreaDeliveryModule instance. If + * obj is an instance of AreaDeliveryModule, delegates to + * equals(AreaDeliveryModule). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -278,7 +285,7 @@ abstract class Delivzone implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return Delivzone The current object, for fluid interface + * @return AreaDeliveryModule The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -310,7 +317,7 @@ abstract class Delivzone implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return Delivzone The current object, for fluid interface + * @return AreaDeliveryModule The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -376,14 +383,14 @@ abstract class Delivzone implements ActiveRecordInterface } /** - * Get the [delivery] column value. + * Get the [delivery_module_id] column value. * - * @return string + * @return int */ - public function getDelivery() + public function getDeliveryModuleId() { - return $this->delivery; + return $this->delivery_module_id; } /** @@ -430,7 +437,7 @@ abstract class Delivzone implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setId($v) { @@ -440,7 +447,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = DelivzoneTableMap::ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::ID; } @@ -451,7 +458,7 @@ abstract class Delivzone implements ActiveRecordInterface * Set the value of [area_id] column. * * @param int $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setAreaId($v) { @@ -461,7 +468,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->area_id !== $v) { $this->area_id = $v; - $this->modifiedColumns[] = DelivzoneTableMap::AREA_ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::AREA_ID; } if ($this->aArea !== null && $this->aArea->getId() !== $v) { @@ -473,32 +480,36 @@ abstract class Delivzone implements ActiveRecordInterface } // setAreaId() /** - * Set the value of [delivery] column. + * Set the value of [delivery_module_id] column. * - * @param string $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ - public function setDelivery($v) + public function setDeliveryModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->delivery !== $v) { - $this->delivery = $v; - $this->modifiedColumns[] = DelivzoneTableMap::DELIVERY; + if ($this->delivery_module_id !== $v) { + $this->delivery_module_id = $v; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; } return $this; - } // setDelivery() + } // setDeliveryModuleId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -506,7 +517,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = DelivzoneTableMap::CREATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::CREATED_AT; } } // if either are not null @@ -519,7 +530,7 @@ abstract class Delivzone implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -527,7 +538,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::UPDATED_AT; } } // if either are not null @@ -572,22 +583,22 @@ abstract class Delivzone implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DelivzoneTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DelivzoneTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; $this->area_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DelivzoneTableMap::translateFieldName('Delivery', TableMap::TYPE_PHPNAME, $indexType)]; - $this->delivery = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DelivzoneTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DelivzoneTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -600,10 +611,10 @@ abstract class Delivzone implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = DelivzoneTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = AreaDeliveryModuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Delivzone object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\AreaDeliveryModule object", 0, $e); } } @@ -625,6 +636,9 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { $this->aArea = null; } + if ($this->aModule !== null && $this->delivery_module_id !== $this->aModule->getId()) { + $this->aModule = null; + } } // ensureConsistency /** @@ -648,13 +662,13 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildDelivzoneQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildAreaDeliveryModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -665,6 +679,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aArea = null; + $this->aModule = null; } // if (deep) } @@ -674,8 +689,8 @@ abstract class Delivzone implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see Delivzone::setDeleted() - * @see Delivzone::isDeleted() + * @see AreaDeliveryModule::setDeleted() + * @see AreaDeliveryModule::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -684,12 +699,12 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildDelivzoneQuery::create() + $deleteQuery = ChildAreaDeliveryModuleQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -726,7 +741,7 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -736,16 +751,16 @@ abstract class Delivzone implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + if (!$this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -757,7 +772,7 @@ abstract class Delivzone implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - DelivzoneTableMap::addInstanceToPool($this); + AreaDeliveryModuleTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -799,6 +814,13 @@ abstract class Delivzone implements ActiveRecordInterface $this->setArea($this->aArea); } + if ($this->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -830,30 +852,30 @@ abstract class Delivzone implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = DelivzoneTableMap::ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzoneTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaDeliveryModuleTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DelivzoneTableMap::ID)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::AREA_ID)) { $modifiedColumns[':p' . $index++] = 'AREA_ID'; } - if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) { - $modifiedColumns[':p' . $index++] = 'DELIVERY'; + if ($this->isColumnModified(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; } - if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO delivzone (%s) VALUES (%s)', + 'INSERT INTO area_delivery_module (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -868,8 +890,8 @@ abstract class Delivzone implements ActiveRecordInterface case 'AREA_ID': $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); break; - case 'DELIVERY': - $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR); + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -923,7 +945,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AreaDeliveryModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -946,7 +968,7 @@ abstract class Delivzone implements ActiveRecordInterface return $this->getAreaId(); break; case 2: - return $this->getDelivery(); + return $this->getDeliveryModuleId(); break; case 3: return $this->getCreatedAt(); @@ -977,15 +999,15 @@ abstract class Delivzone implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['AreaDeliveryModule'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true; - $keys = DelivzoneTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['AreaDeliveryModule'][$this->getPrimaryKey()] = true; + $keys = AreaDeliveryModuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), - $keys[2] => $this->getDelivery(), + $keys[2] => $this->getDeliveryModuleId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -999,6 +1021,9 @@ abstract class Delivzone implements ActiveRecordInterface if (null !== $this->aArea) { $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1017,7 +1042,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AreaDeliveryModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1040,7 +1065,7 @@ abstract class Delivzone implements ActiveRecordInterface $this->setAreaId($value); break; case 2: - $this->setDelivery($value); + $this->setDeliveryModuleId($value); break; case 3: $this->setCreatedAt($value); @@ -1070,11 +1095,11 @@ abstract class Delivzone implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = DelivzoneTableMap::getFieldNames($keyType); + $keys = AreaDeliveryModuleTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDelivery($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setDeliveryModuleId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -1086,13 +1111,13 @@ abstract class Delivzone implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); - if ($this->isColumnModified(DelivzoneTableMap::ID)) $criteria->add(DelivzoneTableMap::ID, $this->id); - if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) $criteria->add(DelivzoneTableMap::AREA_ID, $this->area_id); - if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) $criteria->add(DelivzoneTableMap::DELIVERY, $this->delivery); - if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) $criteria->add(DelivzoneTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) $criteria->add(DelivzoneTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::ID)) $criteria->add(AreaDeliveryModuleTableMap::ID, $this->id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::AREA_ID)) $criteria->add(AreaDeliveryModuleTableMap::AREA_ID, $this->area_id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID)) $criteria->add(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) $criteria->add(AreaDeliveryModuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) $criteria->add(AreaDeliveryModuleTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1107,8 +1132,8 @@ abstract class Delivzone implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); - $criteria->add(DelivzoneTableMap::ID, $this->id); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); + $criteria->add(AreaDeliveryModuleTableMap::ID, $this->id); return $criteria; } @@ -1149,7 +1174,7 @@ abstract class Delivzone implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\Delivzone (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\AreaDeliveryModule (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1157,7 +1182,7 @@ abstract class Delivzone implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setAreaId($this->getAreaId()); - $copyObj->setDelivery($this->getDelivery()); + $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1175,7 +1200,7 @@ abstract class Delivzone implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Delivzone Clone of current object. + * @return \Thelia\Model\AreaDeliveryModule Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1192,7 +1217,7 @@ abstract class Delivzone implements ActiveRecordInterface * Declares an association between this object and a ChildArea object. * * @param ChildArea $v - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) * @throws PropelException */ public function setArea(ChildArea $v = null) @@ -1208,7 +1233,7 @@ abstract class Delivzone implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildArea object, it will not be re-added. if ($v !== null) { - $v->addDelivzone($this); + $v->addAreaDeliveryModule($this); } @@ -1232,13 +1257,64 @@ abstract class Delivzone implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aArea->addDelivzones($this); + $this->aArea->addAreaDeliveryModules($this); */ } return $this->aArea; } + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setDeliveryModuleId(NULL); + } else { + $this->setDeliveryModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addAreaDeliveryModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->delivery_module_id !== null)) { + $this->aModule = ChildModuleQuery::create()->findPk($this->delivery_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModule->addAreaDeliveryModules($this); + */ + } + + return $this->aModule; + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1246,7 +1322,7 @@ abstract class Delivzone implements ActiveRecordInterface { $this->id = null; $this->area_id = null; - $this->delivery = null; + $this->delivery_module_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1271,6 +1347,7 @@ abstract class Delivzone implements ActiveRecordInterface } // if ($deep) $this->aArea = null; + $this->aModule = null; } /** @@ -1280,7 +1357,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(DelivzoneTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(AreaDeliveryModuleTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1288,11 +1365,11 @@ abstract class Delivzone implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildDelivzone The current object (for fluent API support) + * @return ChildAreaDeliveryModule The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/DelivzoneQuery.php b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php similarity index 53% rename from core/lib/Thelia/Model/Base/DelivzoneQuery.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php index e4b8a8ab5..394fe651e 100644 --- a/core/lib/Thelia/Model/Base/DelivzoneQuery.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php @@ -12,80 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; -use Thelia\Model\Map\DelivzoneTableMap; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; +use Thelia\Model\Map\AreaDeliveryModuleTableMap; /** - * Base class that represents a query for the 'delivzone' table. + * Base class that represents a query for the 'area_delivery_module' table. * * * - * @method ChildDelivzoneQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildDelivzoneQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column - * @method ChildDelivzoneQuery orderByDelivery($order = Criteria::ASC) Order by the delivery column - * @method ChildDelivzoneQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildDelivzoneQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildAreaDeliveryModuleQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildAreaDeliveryModuleQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column + * @method ChildAreaDeliveryModuleQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column + * @method ChildAreaDeliveryModuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ChildAreaDeliveryModuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * - * @method ChildDelivzoneQuery groupById() Group by the id column - * @method ChildDelivzoneQuery groupByAreaId() Group by the area_id column - * @method ChildDelivzoneQuery groupByDelivery() Group by the delivery column - * @method ChildDelivzoneQuery groupByCreatedAt() Group by the created_at column - * @method ChildDelivzoneQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildAreaDeliveryModuleQuery groupById() Group by the id column + * @method ChildAreaDeliveryModuleQuery groupByAreaId() Group by the area_id column + * @method ChildAreaDeliveryModuleQuery groupByDeliveryModuleId() Group by the delivery_module_id column + * @method ChildAreaDeliveryModuleQuery groupByCreatedAt() Group by the created_at column + * @method ChildAreaDeliveryModuleQuery groupByUpdatedAt() Group by the updated_at column * - * @method ChildDelivzoneQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildDelivzoneQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildDelivzoneQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildDelivzoneQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation - * @method ChildDelivzoneQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation - * @method ChildDelivzoneQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation * - * @method ChildDelivzone findOne(ConnectionInterface $con = null) Return the first ChildDelivzone matching the query - * @method ChildDelivzone findOneOrCreate(ConnectionInterface $con = null) Return the first ChildDelivzone matching the query, or a new ChildDelivzone object populated from the query conditions when no match is found + * @method ChildAreaDeliveryModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation + * @method ChildAreaDeliveryModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation + * @method ChildAreaDeliveryModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation * - * @method ChildDelivzone findOneById(int $id) Return the first ChildDelivzone filtered by the id column - * @method ChildDelivzone findOneByAreaId(int $area_id) Return the first ChildDelivzone filtered by the area_id column - * @method ChildDelivzone findOneByDelivery(string $delivery) Return the first ChildDelivzone filtered by the delivery column - * @method ChildDelivzone findOneByCreatedAt(string $created_at) Return the first ChildDelivzone filtered by the created_at column - * @method ChildDelivzone findOneByUpdatedAt(string $updated_at) Return the first ChildDelivzone filtered by the updated_at column + * @method ChildAreaDeliveryModule findOne(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query + * @method ChildAreaDeliveryModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query, or a new ChildAreaDeliveryModule object populated from the query conditions when no match is found * - * @method array findById(int $id) Return ChildDelivzone objects filtered by the id column - * @method array findByAreaId(int $area_id) Return ChildDelivzone objects filtered by the area_id column - * @method array findByDelivery(string $delivery) Return ChildDelivzone objects filtered by the delivery column - * @method array findByCreatedAt(string $created_at) Return ChildDelivzone objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildDelivzone objects filtered by the updated_at column + * @method ChildAreaDeliveryModule findOneById(int $id) Return the first ChildAreaDeliveryModule filtered by the id column + * @method ChildAreaDeliveryModule findOneByAreaId(int $area_id) Return the first ChildAreaDeliveryModule filtered by the area_id column + * @method ChildAreaDeliveryModule findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildAreaDeliveryModule filtered by the delivery_module_id column + * @method ChildAreaDeliveryModule findOneByCreatedAt(string $created_at) Return the first ChildAreaDeliveryModule filtered by the created_at column + * @method ChildAreaDeliveryModule findOneByUpdatedAt(string $updated_at) Return the first ChildAreaDeliveryModule filtered by the updated_at column + * + * @method array findById(int $id) Return ChildAreaDeliveryModule objects filtered by the id column + * @method array findByAreaId(int $area_id) Return ChildAreaDeliveryModule objects filtered by the area_id column + * @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildAreaDeliveryModule objects filtered by the delivery_module_id column + * @method array findByCreatedAt(string $created_at) Return ChildAreaDeliveryModule objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ChildAreaDeliveryModule objects filtered by the updated_at column * */ -abstract class DelivzoneQuery extends ModelCriteria +abstract class AreaDeliveryModuleQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\DelivzoneQuery object. + * Initializes internal state of \Thelia\Model\Base\AreaDeliveryModuleQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\Delivzone', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AreaDeliveryModule', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildDelivzoneQuery object. + * Returns a new ChildAreaDeliveryModuleQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildDelivzoneQuery + * @return ChildAreaDeliveryModuleQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\DelivzoneQuery) { + if ($criteria instanceof \Thelia\Model\AreaDeliveryModuleQuery) { return $criteria; } - $query = new \Thelia\Model\DelivzoneQuery(); + $query = new \Thelia\Model\AreaDeliveryModuleQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -108,19 +112,19 @@ abstract class DelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildDelivzone|array|mixed the result, formatted by the current formatter + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = DelivzoneTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -139,11 +143,11 @@ abstract class DelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildDelivzone A model object, or null if the key is not found + * @return ChildAreaDeliveryModule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, AREA_ID, DELIVERY, CREATED_AT, UPDATED_AT FROM delivzone WHERE ID = :p0'; + $sql = 'SELECT ID, AREA_ID, DELIVERY_MODULE_ID, CREATED_AT, UPDATED_AT FROM area_delivery_module WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -154,9 +158,9 @@ abstract class DelivzoneQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildDelivzone(); + $obj = new ChildAreaDeliveryModule(); $obj->hydrate($row); - DelivzoneTableMap::addInstanceToPool($obj, (string) $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -169,7 +173,7 @@ abstract class DelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildDelivzone|array|mixed the result, formatted by the current formatter + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -211,12 +215,12 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(DelivzoneTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -224,12 +228,12 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(DelivzoneTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $keys, Criteria::IN); } /** @@ -248,18 +252,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(DelivzoneTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DelivzoneTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -270,7 +274,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::ID, $id, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id, $comparison); } /** @@ -291,18 +295,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByAreaId($areaId = null, $comparison = null) { if (is_array($areaId)) { $useMinMax = false; if (isset($areaId['min'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($areaId['max'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -313,36 +317,50 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId, $comparison); } /** - * Filter the query on the delivery column + * Filter the query on the delivery_module_id column * * Example usage: * - * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue' - * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%' + * $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234 + * $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34) + * $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12 * * - * @param string $delivery The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModule() + * + * @param mixed $deliveryModuleId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByDelivery($delivery = null, $comparison = null) + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($delivery)) { + if (is_array($deliveryModuleId)) { + $useMinMax = false; + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $delivery)) { - $delivery = str_replace('*', '%', $delivery); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(DelivzoneTableMap::DELIVERY, $delivery, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); } /** @@ -363,18 +381,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByCreatedAt($createdAt = null, $comparison = null) { if (is_array($createdAt)) { $useMinMax = false; if (isset($createdAt['min'])) { - $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -385,7 +403,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -406,18 +424,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByUpdatedAt($updatedAt = null, $comparison = null) { if (is_array($updatedAt)) { $useMinMax = false; if (isset($updatedAt['min'])) { - $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -428,7 +446,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -437,20 +455,20 @@ abstract class DelivzoneQuery extends ModelCriteria * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByArea($area, $comparison = null) { if ($area instanceof \Thelia\Model\Area) { return $this - ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->getId(), $comparison); + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->getId(), $comparison); } elseif ($area instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); } @@ -462,9 +480,9 @@ abstract class DelivzoneQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Area'); @@ -499,7 +517,7 @@ abstract class DelivzoneQuery extends ModelCriteria * * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query */ - public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinArea($relationAlias, $joinType) @@ -507,23 +525,98 @@ abstract class DelivzoneQuery extends ModelCriteria } /** - * Exclude object from result + * Filter the query by a related \Thelia\Model\Module object * - * @param ChildDelivzone $delivzone Object to remove from the list of results + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function prune($delivzone = null) + public function filterByModule($module, $comparison = null) { - if ($delivzone) { - $this->addUsingAlias(DelivzoneTableMap::ID, $delivzone->getId(), Criteria::NOT_EQUAL); + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Module'); } return $this; } /** - * Deletes all rows from the delivzone table. + * Use the Module relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * Exclude object from result + * + * @param ChildAreaDeliveryModule $areaDeliveryModule Object to remove from the list of results + * + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface + */ + public function prune($areaDeliveryModule = null) + { + if ($areaDeliveryModule) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $areaDeliveryModule->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the area_delivery_module table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -531,7 +624,7 @@ abstract class DelivzoneQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -542,8 +635,8 @@ abstract class DelivzoneQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - DelivzoneTableMap::clearInstancePool(); - DelivzoneTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -555,9 +648,9 @@ abstract class DelivzoneQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildDelivzone or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildAreaDeliveryModule or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildDelivzone object or primary key or array of primary keys + * @param mixed $values Criteria or ChildAreaDeliveryModule object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -568,13 +661,13 @@ abstract class DelivzoneQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(DelivzoneTableMap::DATABASE_NAME); + $criteria->setDbName(AreaDeliveryModuleTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -584,10 +677,10 @@ abstract class DelivzoneQuery extends ModelCriteria $con->beginTransaction(); - DelivzoneTableMap::removeInstanceFromPool($criteria); + AreaDeliveryModuleTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - DelivzoneTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -604,11 +697,11 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function recentlyUpdated($nbDays = 7) { - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -616,51 +709,51 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function recentlyCreated($nbDays = 7) { - return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } -} // DelivzoneQuery +} // AreaDeliveryModuleQuery diff --git a/core/lib/Thelia/Model/Base/AreaQuery.php b/core/lib/Thelia/Model/Base/AreaQuery.php index f583a30dd..ea4cd8b90 100644 --- a/core/lib/Thelia/Model/Base/AreaQuery.php +++ b/core/lib/Thelia/Model/Base/AreaQuery.php @@ -23,13 +23,13 @@ use Thelia\Model\Map\AreaTableMap; * * @method ChildAreaQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildAreaQuery orderByName($order = Criteria::ASC) Order by the name column - * @method ChildAreaQuery orderByUnit($order = Criteria::ASC) Order by the unit column + * @method ChildAreaQuery orderByPostage($order = Criteria::ASC) Order by the postage column * @method ChildAreaQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAreaQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAreaQuery groupById() Group by the id column * @method ChildAreaQuery groupByName() Group by the name column - * @method ChildAreaQuery groupByUnit() Group by the unit column + * @method ChildAreaQuery groupByPostage() Group by the postage column * @method ChildAreaQuery groupByCreatedAt() Group by the created_at column * @method ChildAreaQuery groupByUpdatedAt() Group by the updated_at column * @@ -41,22 +41,22 @@ use Thelia\Model\Map\AreaTableMap; * @method ChildAreaQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation * @method ChildAreaQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation * - * @method ChildAreaQuery leftJoinDelivzone($relationAlias = null) Adds a LEFT JOIN clause to the query using the Delivzone relation - * @method ChildAreaQuery rightJoinDelivzone($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Delivzone relation - * @method ChildAreaQuery innerJoinDelivzone($relationAlias = null) Adds a INNER JOIN clause to the query using the Delivzone relation + * @method ChildAreaQuery leftJoinAreaDeliveryModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildAreaQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildAreaQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation * * @method ChildArea findOne(ConnectionInterface $con = null) Return the first ChildArea matching the query * @method ChildArea findOneOrCreate(ConnectionInterface $con = null) Return the first ChildArea matching the query, or a new ChildArea object populated from the query conditions when no match is found * * @method ChildArea findOneById(int $id) Return the first ChildArea filtered by the id column * @method ChildArea findOneByName(string $name) Return the first ChildArea filtered by the name column - * @method ChildArea findOneByUnit(double $unit) Return the first ChildArea filtered by the unit column + * @method ChildArea findOneByPostage(double $postage) Return the first ChildArea filtered by the postage column * @method ChildArea findOneByCreatedAt(string $created_at) Return the first ChildArea filtered by the created_at column * @method ChildArea findOneByUpdatedAt(string $updated_at) Return the first ChildArea filtered by the updated_at column * * @method array findById(int $id) Return ChildArea objects filtered by the id column * @method array findByName(string $name) Return ChildArea objects filtered by the name column - * @method array findByUnit(double $unit) Return ChildArea objects filtered by the unit column + * @method array findByPostage(double $postage) Return ChildArea objects filtered by the postage column * @method array findByCreatedAt(string $created_at) Return ChildArea objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildArea objects filtered by the updated_at column * @@ -147,7 +147,7 @@ abstract class AreaQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, NAME, UNIT, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0'; + $sql = 'SELECT ID, NAME, POSTAGE, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -307,16 +307,16 @@ abstract class AreaQuery extends ModelCriteria } /** - * Filter the query on the unit column + * Filter the query on the postage column * * Example usage: * - * $query->filterByUnit(1234); // WHERE unit = 1234 - * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34) - * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12 + * $query->filterByPostage(1234); // WHERE postage = 1234 + * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34) + * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12 * * - * @param mixed $unit The value to use as filter. + * @param mixed $postage The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -324,16 +324,16 @@ abstract class AreaQuery extends ModelCriteria * * @return ChildAreaQuery The current query, for fluid interface */ - public function filterByUnit($unit = null, $comparison = null) + public function filterByPostage($postage = null, $comparison = null) { - if (is_array($unit)) { + if (is_array($postage)) { $useMinMax = false; - if (isset($unit['min'])) { - $this->addUsingAlias(AreaTableMap::UNIT, $unit['min'], Criteria::GREATER_EQUAL); + if (isset($postage['min'])) { + $this->addUsingAlias(AreaTableMap::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($unit['max'])) { - $this->addUsingAlias(AreaTableMap::UNIT, $unit['max'], Criteria::LESS_EQUAL); + if (isset($postage['max'])) { + $this->addUsingAlias(AreaTableMap::POSTAGE, $postage['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -344,7 +344,7 @@ abstract class AreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaTableMap::UNIT, $unit, $comparison); + return $this->addUsingAlias(AreaTableMap::POSTAGE, $postage, $comparison); } /** @@ -507,40 +507,40 @@ abstract class AreaQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Delivzone object + * Filter the query by a related \Thelia\Model\AreaDeliveryModule object * - * @param \Thelia\Model\Delivzone|ObjectCollection $delivzone the related object to use as filter + * @param \Thelia\Model\AreaDeliveryModule|ObjectCollection $areaDeliveryModule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAreaQuery The current query, for fluid interface */ - public function filterByDelivzone($delivzone, $comparison = null) + public function filterByAreaDeliveryModule($areaDeliveryModule, $comparison = null) { - if ($delivzone instanceof \Thelia\Model\Delivzone) { + if ($areaDeliveryModule instanceof \Thelia\Model\AreaDeliveryModule) { return $this - ->addUsingAlias(AreaTableMap::ID, $delivzone->getAreaId(), $comparison); - } elseif ($delivzone instanceof ObjectCollection) { + ->addUsingAlias(AreaTableMap::ID, $areaDeliveryModule->getAreaId(), $comparison); + } elseif ($areaDeliveryModule instanceof ObjectCollection) { return $this - ->useDelivzoneQuery() - ->filterByPrimaryKeys($delivzone->getPrimaryKeys()) + ->useAreaDeliveryModuleQuery() + ->filterByPrimaryKeys($areaDeliveryModule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDelivzone() only accepts arguments of type \Thelia\Model\Delivzone or Collection'); + throw new PropelException('filterByAreaDeliveryModule() only accepts arguments of type \Thelia\Model\AreaDeliveryModule or Collection'); } } /** - * Adds a JOIN clause to the query using the Delivzone relation + * Adds a JOIN clause to the query using the AreaDeliveryModule relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildAreaQuery The current query, for fluid interface */ - public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinAreaDeliveryModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Delivzone'); + $relationMap = $tableMap->getRelation('AreaDeliveryModule'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -555,14 +555,14 @@ abstract class AreaQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Delivzone'); + $this->addJoinObject($join, 'AreaDeliveryModule'); } return $this; } /** - * Use the Delivzone relation Delivzone object + * Use the AreaDeliveryModule relation AreaDeliveryModule object * * @see useQuery() * @@ -570,13 +570,13 @@ abstract class AreaQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\DelivzoneQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AreaDeliveryModuleQuery A secondary query class using the current class as primary query */ - public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAreaDeliveryModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinDelivzone($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery'); + ->joinAreaDeliveryModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AreaDeliveryModule', '\Thelia\Model\AreaDeliveryModuleQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index 3c754c3b5..64e765fdd 100644 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -20,15 +20,15 @@ use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Attribute as ChildAttribute; use Thelia\Model\AttributeAv as ChildAttributeAv; use Thelia\Model\AttributeAvQuery as ChildAttributeAvQuery; -use Thelia\Model\AttributeCategory as ChildAttributeCategory; -use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; use Thelia\Model\AttributeCombination as ChildAttributeCombination; use Thelia\Model\AttributeCombinationQuery as ChildAttributeCombinationQuery; use Thelia\Model\AttributeI18n as ChildAttributeI18n; use Thelia\Model\AttributeI18nQuery as ChildAttributeI18nQuery; use Thelia\Model\AttributeQuery as ChildAttributeQuery; -use Thelia\Model\Category as ChildCategory; -use Thelia\Model\CategoryQuery as ChildCategoryQuery; +use Thelia\Model\AttributeTemplate as ChildAttributeTemplate; +use Thelia\Model\AttributeTemplateQuery as ChildAttributeTemplateQuery; +use Thelia\Model\Template as ChildTemplate; +use Thelia\Model\TemplateQuery as ChildTemplateQuery; use Thelia\Model\Map\AttributeTableMap; abstract class Attribute implements ActiveRecordInterface @@ -102,10 +102,10 @@ abstract class Attribute implements ActiveRecordInterface protected $collAttributeCombinationsPartial; /** - * @var ObjectCollection|ChildAttributeCategory[] Collection to store aggregation of ChildAttributeCategory objects. + * @var ObjectCollection|ChildAttributeTemplate[] Collection to store aggregation of ChildAttributeTemplate objects. */ - protected $collAttributeCategories; - protected $collAttributeCategoriesPartial; + protected $collAttributeTemplates; + protected $collAttributeTemplatesPartial; /** * @var ObjectCollection|ChildAttributeI18n[] Collection to store aggregation of ChildAttributeI18n objects. @@ -114,9 +114,9 @@ abstract class Attribute implements ActiveRecordInterface protected $collAttributeI18nsPartial; /** - * @var ChildCategory[] Collection to store aggregation of ChildCategory objects. + * @var ChildTemplate[] Collection to store aggregation of ChildTemplate objects. */ - protected $collCategories; + protected $collTemplates; /** * Flag to prevent endless save loop, if this object is referenced @@ -144,7 +144,7 @@ abstract class Attribute implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $categoriesScheduledForDeletion = null; + protected $templatesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -162,7 +162,7 @@ abstract class Attribute implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $attributeCategoriesScheduledForDeletion = null; + protected $attributeTemplatesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -697,11 +697,11 @@ abstract class Attribute implements ActiveRecordInterface $this->collAttributeCombinations = null; - $this->collAttributeCategories = null; + $this->collAttributeTemplates = null; $this->collAttributeI18ns = null; - $this->collCategories = null; + $this->collTemplates = null; } // if (deep) } @@ -835,29 +835,29 @@ abstract class Attribute implements ActiveRecordInterface $this->resetModified(); } - if ($this->categoriesScheduledForDeletion !== null) { - if (!$this->categoriesScheduledForDeletion->isEmpty()) { + if ($this->templatesScheduledForDeletion !== null) { + if (!$this->templatesScheduledForDeletion->isEmpty()) { $pks = array(); $pk = $this->getPrimaryKey(); - foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); + foreach ($this->templatesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pks[] = array($pk, $remotePk); } - AttributeCategoryQuery::create() + AttributeTemplateQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->categoriesScheduledForDeletion = null; + $this->templatesScheduledForDeletion = null; } - foreach ($this->getCategories() as $category) { - if ($category->isModified()) { - $category->save($con); + foreach ($this->getTemplates() as $template) { + if ($template->isModified()) { + $template->save($con); } } - } elseif ($this->collCategories) { - foreach ($this->collCategories as $category) { - if ($category->isModified()) { - $category->save($con); + } elseif ($this->collTemplates) { + foreach ($this->collTemplates as $template) { + if ($template->isModified()) { + $template->save($con); } } } @@ -896,17 +896,17 @@ abstract class Attribute implements ActiveRecordInterface } } - if ($this->attributeCategoriesScheduledForDeletion !== null) { - if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) { - \Thelia\Model\AttributeCategoryQuery::create() - ->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->attributeTemplatesScheduledForDeletion !== null) { + if (!$this->attributeTemplatesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AttributeTemplateQuery::create() + ->filterByPrimaryKeys($this->attributeTemplatesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->attributeCategoriesScheduledForDeletion = null; + $this->attributeTemplatesScheduledForDeletion = null; } } - if ($this->collAttributeCategories !== null) { - foreach ($this->collAttributeCategories as $referrerFK) { + if ($this->collAttributeTemplates !== null) { + foreach ($this->collAttributeTemplates as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1112,8 +1112,8 @@ abstract class Attribute implements ActiveRecordInterface if (null !== $this->collAttributeCombinations) { $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collAttributeCategories) { - $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAttributeTemplates) { + $result['AttributeTemplates'] = $this->collAttributeTemplates->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collAttributeI18ns) { $result['AttributeI18ns'] = $this->collAttributeI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1291,9 +1291,9 @@ abstract class Attribute implements ActiveRecordInterface } } - foreach ($this->getAttributeCategories() as $relObj) { + foreach ($this->getAttributeTemplates() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCategory($relObj->copy($deepCopy)); + $copyObj->addAttributeTemplate($relObj->copy($deepCopy)); } } @@ -1350,8 +1350,8 @@ abstract class Attribute implements ActiveRecordInterface if ('AttributeCombination' == $relationName) { return $this->initAttributeCombinations(); } - if ('AttributeCategory' == $relationName) { - return $this->initAttributeCategories(); + if ('AttributeTemplate' == $relationName) { + return $this->initAttributeTemplates(); } if ('AttributeI18n' == $relationName) { return $this->initAttributeI18ns(); @@ -1848,31 +1848,31 @@ abstract class Attribute implements ActiveRecordInterface } /** - * Clears out the collAttributeCategories collection + * Clears out the collAttributeTemplates collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addAttributeCategories() + * @see addAttributeTemplates() */ - public function clearAttributeCategories() + public function clearAttributeTemplates() { - $this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized + $this->collAttributeTemplates = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collAttributeCategories collection loaded partially. + * Reset is the collAttributeTemplates collection loaded partially. */ - public function resetPartialAttributeCategories($v = true) + public function resetPartialAttributeTemplates($v = true) { - $this->collAttributeCategoriesPartial = $v; + $this->collAttributeTemplatesPartial = $v; } /** - * Initializes the collAttributeCategories collection. + * Initializes the collAttributeTemplates collection. * - * By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories()); + * By default this just sets the collAttributeTemplates collection to an empty array (like clearcollAttributeTemplates()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1881,17 +1881,17 @@ abstract class Attribute implements ActiveRecordInterface * * @return void */ - public function initAttributeCategories($overrideExisting = true) + public function initAttributeTemplates($overrideExisting = true) { - if (null !== $this->collAttributeCategories && !$overrideExisting) { + if (null !== $this->collAttributeTemplates && !$overrideExisting) { return; } - $this->collAttributeCategories = new ObjectCollection(); - $this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory'); + $this->collAttributeTemplates = new ObjectCollection(); + $this->collAttributeTemplates->setModel('\Thelia\Model\AttributeTemplate'); } /** - * Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeTemplate objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1901,109 +1901,109 @@ abstract class Attribute implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects + * @return Collection|ChildAttributeTemplate[] List of ChildAttributeTemplate objects * @throws PropelException */ - public function getAttributeCategories($criteria = null, ConnectionInterface $con = null) + public function getAttributeTemplates($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); - if (null === $this->collAttributeCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategories) { + $partial = $this->collAttributeTemplatesPartial && !$this->isNew(); + if (null === $this->collAttributeTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeTemplates) { // return empty collection - $this->initAttributeCategories(); + $this->initAttributeTemplates(); } else { - $collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria) + $collAttributeTemplates = ChildAttributeTemplateQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) { - $this->initAttributeCategories(false); + if (false !== $this->collAttributeTemplatesPartial && count($collAttributeTemplates)) { + $this->initAttributeTemplates(false); - foreach ($collAttributeCategories as $obj) { - if (false == $this->collAttributeCategories->contains($obj)) { - $this->collAttributeCategories->append($obj); + foreach ($collAttributeTemplates as $obj) { + if (false == $this->collAttributeTemplates->contains($obj)) { + $this->collAttributeTemplates->append($obj); } } - $this->collAttributeCategoriesPartial = true; + $this->collAttributeTemplatesPartial = true; } - $collAttributeCategories->getInternalIterator()->rewind(); + $collAttributeTemplates->getInternalIterator()->rewind(); - return $collAttributeCategories; + return $collAttributeTemplates; } - if ($partial && $this->collAttributeCategories) { - foreach ($this->collAttributeCategories as $obj) { + if ($partial && $this->collAttributeTemplates) { + foreach ($this->collAttributeTemplates as $obj) { if ($obj->isNew()) { - $collAttributeCategories[] = $obj; + $collAttributeTemplates[] = $obj; } } } - $this->collAttributeCategories = $collAttributeCategories; - $this->collAttributeCategoriesPartial = false; + $this->collAttributeTemplates = $collAttributeTemplates; + $this->collAttributeTemplatesPartial = false; } } - return $this->collAttributeCategories; + return $this->collAttributeTemplates; } /** - * Sets a collection of AttributeCategory objects related by a one-to-many relationship + * Sets a collection of AttributeTemplate objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $attributeCategories A Propel collection. + * @param Collection $attributeTemplates A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildAttribute The current object (for fluent API support) */ - public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null) + public function setAttributeTemplates(Collection $attributeTemplates, ConnectionInterface $con = null) { - $attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories); + $attributeTemplatesToDelete = $this->getAttributeTemplates(new Criteria(), $con)->diff($attributeTemplates); - $this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete; + $this->attributeTemplatesScheduledForDeletion = $attributeTemplatesToDelete; - foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) { - $attributeCategoryRemoved->setAttribute(null); + foreach ($attributeTemplatesToDelete as $attributeTemplateRemoved) { + $attributeTemplateRemoved->setAttribute(null); } - $this->collAttributeCategories = null; - foreach ($attributeCategories as $attributeCategory) { - $this->addAttributeCategory($attributeCategory); + $this->collAttributeTemplates = null; + foreach ($attributeTemplates as $attributeTemplate) { + $this->addAttributeTemplate($attributeTemplate); } - $this->collAttributeCategories = $attributeCategories; - $this->collAttributeCategoriesPartial = false; + $this->collAttributeTemplates = $attributeTemplates; + $this->collAttributeTemplatesPartial = false; return $this; } /** - * Returns the number of related AttributeCategory objects. + * Returns the number of related AttributeTemplate objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related AttributeCategory objects. + * @return int Count of related AttributeTemplate objects. * @throws PropelException */ - public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countAttributeTemplates(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); - if (null === $this->collAttributeCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategories) { + $partial = $this->collAttributeTemplatesPartial && !$this->isNew(); + if (null === $this->collAttributeTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeTemplates) { return 0; } if ($partial && !$criteria) { - return count($this->getAttributeCategories()); + return count($this->getAttributeTemplates()); } - $query = ChildAttributeCategoryQuery::create(null, $criteria); + $query = ChildAttributeTemplateQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2013,53 +2013,53 @@ abstract class Attribute implements ActiveRecordInterface ->count($con); } - return count($this->collAttributeCategories); + return count($this->collAttributeTemplates); } /** - * Method called to associate a ChildAttributeCategory object to this object - * through the ChildAttributeCategory foreign key attribute. + * Method called to associate a ChildAttributeTemplate object to this object + * through the ChildAttributeTemplate foreign key attribute. * - * @param ChildAttributeCategory $l ChildAttributeCategory + * @param ChildAttributeTemplate $l ChildAttributeTemplate * @return \Thelia\Model\Attribute The current object (for fluent API support) */ - public function addAttributeCategory(ChildAttributeCategory $l) + public function addAttributeTemplate(ChildAttributeTemplate $l) { - if ($this->collAttributeCategories === null) { - $this->initAttributeCategories(); - $this->collAttributeCategoriesPartial = true; + if ($this->collAttributeTemplates === null) { + $this->initAttributeTemplates(); + $this->collAttributeTemplatesPartial = true; } - if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCategory($l); + if (!in_array($l, $this->collAttributeTemplates->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAttributeTemplate($l); } return $this; } /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. + * @param AttributeTemplate $attributeTemplate The attributeTemplate object to add. */ - protected function doAddAttributeCategory($attributeCategory) + protected function doAddAttributeTemplate($attributeTemplate) { - $this->collAttributeCategories[]= $attributeCategory; - $attributeCategory->setAttribute($this); + $this->collAttributeTemplates[]= $attributeTemplate; + $attributeTemplate->setAttribute($this); } /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. + * @param AttributeTemplate $attributeTemplate The attributeTemplate object to remove. * @return ChildAttribute The current object (for fluent API support) */ - public function removeAttributeCategory($attributeCategory) + public function removeAttributeTemplate($attributeTemplate) { - if ($this->getAttributeCategories()->contains($attributeCategory)) { - $this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory)); - if (null === $this->attributeCategoriesScheduledForDeletion) { - $this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories; - $this->attributeCategoriesScheduledForDeletion->clear(); + if ($this->getAttributeTemplates()->contains($attributeTemplate)) { + $this->collAttributeTemplates->remove($this->collAttributeTemplates->search($attributeTemplate)); + if (null === $this->attributeTemplatesScheduledForDeletion) { + $this->attributeTemplatesScheduledForDeletion = clone $this->collAttributeTemplates; + $this->attributeTemplatesScheduledForDeletion->clear(); } - $this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory; - $attributeCategory->setAttribute(null); + $this->attributeTemplatesScheduledForDeletion[]= clone $attributeTemplate; + $attributeTemplate->setAttribute(null); } return $this; @@ -2071,7 +2071,7 @@ abstract class Attribute implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this Attribute is new, it will return * an empty collection; or if this Attribute has previously - * been saved, it will retrieve related AttributeCategories from storage. + * been saved, it will retrieve related AttributeTemplates from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2080,14 +2080,14 @@ abstract class Attribute implements ActiveRecordInterface * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects + * @return Collection|ChildAttributeTemplate[] List of ChildAttributeTemplate objects */ - public function getAttributeCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getAttributeTemplatesJoinTemplate($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ChildAttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); + $query = ChildAttributeTemplateQuery::create(null, $criteria); + $query->joinWith('Template', $joinBehavior); - return $this->getAttributeCategories($query, $con); + return $this->getAttributeTemplates($query, $con); } /** @@ -2316,38 +2316,38 @@ abstract class Attribute implements ActiveRecordInterface } /** - * Clears out the collCategories collection + * Clears out the collTemplates collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addCategories() + * @see addTemplates() */ - public function clearCategories() + public function clearTemplates() { - $this->collCategories = null; // important to set this to NULL since that means it is uninitialized - $this->collCategoriesPartial = null; + $this->collTemplates = null; // important to set this to NULL since that means it is uninitialized + $this->collTemplatesPartial = null; } /** - * Initializes the collCategories collection. + * Initializes the collTemplates collection. * - * By default this just sets the collCategories collection to an empty collection (like clearCategories()); + * By default this just sets the collTemplates collection to an empty collection (like clearTemplates()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * * @return void */ - public function initCategories() + public function initTemplates() { - $this->collCategories = new ObjectCollection(); - $this->collCategories->setModel('\Thelia\Model\Category'); + $this->collTemplates = new ObjectCollection(); + $this->collTemplates->setModel('\Thelia\Model\Template'); } /** - * Gets a collection of ChildCategory objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. + * Gets a collection of ChildTemplate objects related by a many-to-many relationship + * to the current object by way of the attribute_template cross-reference table. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -2358,73 +2358,73 @@ abstract class Attribute implements ActiveRecordInterface * @param Criteria $criteria Optional query object to filter the query * @param ConnectionInterface $con Optional connection object * - * @return ObjectCollection|ChildCategory[] List of ChildCategory objects + * @return ObjectCollection|ChildTemplate[] List of ChildTemplate objects */ - public function getCategories($criteria = null, ConnectionInterface $con = null) + public function getTemplates($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collCategories || null !== $criteria) { - if ($this->isNew() && null === $this->collCategories) { + if (null === $this->collTemplates || null !== $criteria) { + if ($this->isNew() && null === $this->collTemplates) { // return empty collection - $this->initCategories(); + $this->initTemplates(); } else { - $collCategories = ChildCategoryQuery::create(null, $criteria) + $collTemplates = ChildTemplateQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); if (null !== $criteria) { - return $collCategories; + return $collTemplates; } - $this->collCategories = $collCategories; + $this->collTemplates = $collTemplates; } } - return $this->collCategories; + return $this->collTemplates; } /** - * Sets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. + * Sets a collection of Template objects related by a many-to-many relationship + * to the current object by way of the attribute_template cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $categories A Propel collection. + * @param Collection $templates A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildAttribute The current object (for fluent API support) */ - public function setCategories(Collection $categories, ConnectionInterface $con = null) + public function setTemplates(Collection $templates, ConnectionInterface $con = null) { - $this->clearCategories(); - $currentCategories = $this->getCategories(); + $this->clearTemplates(); + $currentTemplates = $this->getTemplates(); - $this->categoriesScheduledForDeletion = $currentCategories->diff($categories); + $this->templatesScheduledForDeletion = $currentTemplates->diff($templates); - foreach ($categories as $category) { - if (!$currentCategories->contains($category)) { - $this->doAddCategory($category); + foreach ($templates as $template) { + if (!$currentTemplates->contains($template)) { + $this->doAddTemplate($template); } } - $this->collCategories = $categories; + $this->collTemplates = $templates; return $this; } /** - * Gets the number of ChildCategory objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. + * Gets the number of ChildTemplate objects related by a many-to-many relationship + * to the current object by way of the attribute_template cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param ConnectionInterface $con Optional connection object * - * @return int the number of related ChildCategory objects + * @return int the number of related ChildTemplate objects */ - public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countTemplates($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collCategories || null !== $criteria) { - if ($this->isNew() && null === $this->collCategories) { + if (null === $this->collTemplates || null !== $criteria) { + if ($this->isNew() && null === $this->collTemplates) { return 0; } else { - $query = ChildCategoryQuery::create(null, $criteria); + $query = ChildTemplateQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2434,65 +2434,65 @@ abstract class Attribute implements ActiveRecordInterface ->count($con); } } else { - return count($this->collCategories); + return count($this->collTemplates); } } /** - * Associate a ChildCategory object to this object - * through the attribute_category cross reference table. + * Associate a ChildTemplate object to this object + * through the attribute_template cross reference table. * - * @param ChildCategory $category The ChildAttributeCategory object to relate + * @param ChildTemplate $template The ChildAttributeTemplate object to relate * @return ChildAttribute The current object (for fluent API support) */ - public function addCategory(ChildCategory $category) + public function addTemplate(ChildTemplate $template) { - if ($this->collCategories === null) { - $this->initCategories(); + if ($this->collTemplates === null) { + $this->initTemplates(); } - if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - $this->collCategories[] = $category; + if (!$this->collTemplates->contains($template)) { // only add it if the **same** object is not already associated + $this->doAddTemplate($template); + $this->collTemplates[] = $template; } return $this; } /** - * @param Category $category The category object to add. + * @param Template $template The template object to add. */ - protected function doAddCategory($category) + protected function doAddTemplate($template) { - $attributeCategory = new ChildAttributeCategory(); - $attributeCategory->setCategory($category); - $this->addAttributeCategory($attributeCategory); + $attributeTemplate = new ChildAttributeTemplate(); + $attributeTemplate->setTemplate($template); + $this->addAttributeTemplate($attributeTemplate); // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations - if (!$category->getAttributes()->contains($this)) { - $foreignCollection = $category->getAttributes(); + if (!$template->getAttributes()->contains($this)) { + $foreignCollection = $template->getAttributes(); $foreignCollection[] = $this; } } /** - * Remove a ChildCategory object to this object - * through the attribute_category cross reference table. + * Remove a ChildTemplate object to this object + * through the attribute_template cross reference table. * - * @param ChildCategory $category The ChildAttributeCategory object to relate + * @param ChildTemplate $template The ChildAttributeTemplate object to relate * @return ChildAttribute The current object (for fluent API support) */ - public function removeCategory(ChildCategory $category) + public function removeTemplate(ChildTemplate $template) { - if ($this->getCategories()->contains($category)) { - $this->collCategories->remove($this->collCategories->search($category)); + if ($this->getTemplates()->contains($template)) { + $this->collTemplates->remove($this->collTemplates->search($template)); - if (null === $this->categoriesScheduledForDeletion) { - $this->categoriesScheduledForDeletion = clone $this->collCategories; - $this->categoriesScheduledForDeletion->clear(); + if (null === $this->templatesScheduledForDeletion) { + $this->templatesScheduledForDeletion = clone $this->collTemplates; + $this->templatesScheduledForDeletion->clear(); } - $this->categoriesScheduledForDeletion[] = $category; + $this->templatesScheduledForDeletion[] = $template; } return $this; @@ -2536,8 +2536,8 @@ abstract class Attribute implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collAttributeCategories) { - foreach ($this->collAttributeCategories as $o) { + if ($this->collAttributeTemplates) { + foreach ($this->collAttributeTemplates as $o) { $o->clearAllReferences($deep); } } @@ -2546,8 +2546,8 @@ abstract class Attribute implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collCategories) { - foreach ($this->collCategories as $o) { + if ($this->collTemplates) { + foreach ($this->collTemplates as $o) { $o->clearAllReferences($deep); } } @@ -2565,18 +2565,18 @@ abstract class Attribute implements ActiveRecordInterface $this->collAttributeCombinations->clearIterator(); } $this->collAttributeCombinations = null; - if ($this->collAttributeCategories instanceof Collection) { - $this->collAttributeCategories->clearIterator(); + if ($this->collAttributeTemplates instanceof Collection) { + $this->collAttributeTemplates->clearIterator(); } - $this->collAttributeCategories = null; + $this->collAttributeTemplates = null; if ($this->collAttributeI18ns instanceof Collection) { $this->collAttributeI18ns->clearIterator(); } $this->collAttributeI18ns = null; - if ($this->collCategories instanceof Collection) { - $this->collCategories->clearIterator(); + if ($this->collTemplates instanceof Collection) { + $this->collTemplates->clearIterator(); } - $this->collCategories = null; + $this->collTemplates = null; } /** diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php index cabbaf7ac..b496289f8 100644 --- a/core/lib/Thelia/Model/Base/AttributeQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeQuery.php @@ -44,9 +44,9 @@ use Thelia\Model\Map\AttributeTableMap; * @method ChildAttributeQuery rightJoinAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCombination relation * @method ChildAttributeQuery innerJoinAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCombination relation * - * @method ChildAttributeQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation - * @method ChildAttributeQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation - * @method ChildAttributeQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation + * @method ChildAttributeQuery leftJoinAttributeTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeTemplate relation + * @method ChildAttributeQuery rightJoinAttributeTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeTemplate relation + * @method ChildAttributeQuery innerJoinAttributeTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeTemplate relation * * @method ChildAttributeQuery leftJoinAttributeI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeI18n relation * @method ChildAttributeQuery rightJoinAttributeI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeI18n relation @@ -556,40 +556,40 @@ abstract class AttributeQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\AttributeCategory object + * Filter the query by a related \Thelia\Model\AttributeTemplate object * - * @param \Thelia\Model\AttributeCategory|ObjectCollection $attributeCategory the related object to use as filter + * @param \Thelia\Model\AttributeTemplate|ObjectCollection $attributeTemplate the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAttributeQuery The current query, for fluid interface */ - public function filterByAttributeCategory($attributeCategory, $comparison = null) + public function filterByAttributeTemplate($attributeTemplate, $comparison = null) { - if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) { + if ($attributeTemplate instanceof \Thelia\Model\AttributeTemplate) { return $this - ->addUsingAlias(AttributeTableMap::ID, $attributeCategory->getAttributeId(), $comparison); - } elseif ($attributeCategory instanceof ObjectCollection) { + ->addUsingAlias(AttributeTableMap::ID, $attributeTemplate->getAttributeId(), $comparison); + } elseif ($attributeTemplate instanceof ObjectCollection) { return $this - ->useAttributeCategoryQuery() - ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) + ->useAttributeTemplateQuery() + ->filterByPrimaryKeys($attributeTemplate->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection'); + throw new PropelException('filterByAttributeTemplate() only accepts arguments of type \Thelia\Model\AttributeTemplate or Collection'); } } /** - * Adds a JOIN clause to the query using the AttributeCategory relation + * Adds a JOIN clause to the query using the AttributeTemplate relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinAttributeTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCategory'); + $relationMap = $tableMap->getRelation('AttributeTemplate'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -604,14 +604,14 @@ abstract class AttributeQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'AttributeCategory'); + $this->addJoinObject($join, 'AttributeTemplate'); } return $this; } /** - * Use the AttributeCategory relation AttributeCategory object + * Use the AttributeTemplate relation AttributeTemplate object * * @see useQuery() * @@ -619,13 +619,13 @@ abstract class AttributeQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AttributeTemplateQuery A secondary query class using the current class as primary query */ - public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useAttributeTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinAttributeCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); + ->joinAttributeTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AttributeTemplate', '\Thelia\Model\AttributeTemplateQuery'); } /** @@ -702,19 +702,19 @@ abstract class AttributeQuery extends ModelCriteria } /** - * Filter the query by a related Category object - * using the attribute_category table as cross reference + * Filter the query by a related Template object + * using the attribute_template table as cross reference * - * @param Category $category the related object to use as filter + * @param Template $template the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAttributeQuery The current query, for fluid interface */ - public function filterByCategory($category, $comparison = Criteria::EQUAL) + public function filterByTemplate($template, $comparison = Criteria::EQUAL) { return $this - ->useAttributeCategoryQuery() - ->filterByCategory($category, $comparison) + ->useAttributeTemplateQuery() + ->filterByTemplate($template, $comparison) ->endUse(); } diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeTemplate.php similarity index 85% rename from core/lib/Thelia/Model/Base/AttributeCategory.php rename to core/lib/Thelia/Model/Base/AttributeTemplate.php index da702559a..cedc85431 100644 --- a/core/lib/Thelia/Model/Base/AttributeCategory.php +++ b/core/lib/Thelia/Model/Base/AttributeTemplate.php @@ -17,19 +17,19 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Attribute as ChildAttribute; -use Thelia\Model\AttributeCategory as ChildAttributeCategory; -use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; use Thelia\Model\AttributeQuery as ChildAttributeQuery; -use Thelia\Model\Category as ChildCategory; -use Thelia\Model\CategoryQuery as ChildCategoryQuery; -use Thelia\Model\Map\AttributeCategoryTableMap; +use Thelia\Model\AttributeTemplate as ChildAttributeTemplate; +use Thelia\Model\AttributeTemplateQuery as ChildAttributeTemplateQuery; +use Thelia\Model\Template as ChildTemplate; +use Thelia\Model\TemplateQuery as ChildTemplateQuery; +use Thelia\Model\Map\AttributeTemplateTableMap; -abstract class AttributeCategory implements ActiveRecordInterface +abstract class AttributeTemplate implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\AttributeCategoryTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\AttributeTemplateTableMap'; /** @@ -64,18 +64,18 @@ abstract class AttributeCategory implements ActiveRecordInterface */ protected $id; - /** - * The value for the category_id field. - * @var int - */ - protected $category_id; - /** * The value for the attribute_id field. * @var int */ protected $attribute_id; + /** + * The value for the template_id field. + * @var int + */ + protected $template_id; + /** * The value for the created_at field. * @var string @@ -88,16 +88,16 @@ abstract class AttributeCategory implements ActiveRecordInterface */ protected $updated_at; - /** - * @var Category - */ - protected $aCategory; - /** * @var Attribute */ protected $aAttribute; + /** + * @var Template + */ + protected $aTemplate; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -107,7 +107,7 @@ abstract class AttributeCategory implements ActiveRecordInterface protected $alreadyInSave = false; /** - * Initializes internal state of Thelia\Model\Base\AttributeCategory object. + * Initializes internal state of Thelia\Model\Base\AttributeTemplate object. */ public function __construct() { @@ -202,9 +202,9 @@ abstract class AttributeCategory implements ActiveRecordInterface } /** - * Compares this with another AttributeCategory instance. If - * obj is an instance of AttributeCategory, delegates to - * equals(AttributeCategory). Otherwise, returns false. + * Compares this with another AttributeTemplate instance. If + * obj is an instance of AttributeTemplate, delegates to + * equals(AttributeTemplate). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -285,7 +285,7 @@ abstract class AttributeCategory implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return AttributeCategory The current object, for fluid interface + * @return AttributeTemplate The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -317,7 +317,7 @@ abstract class AttributeCategory implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return AttributeCategory The current object, for fluid interface + * @return AttributeTemplate The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -371,17 +371,6 @@ abstract class AttributeCategory implements ActiveRecordInterface return $this->id; } - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - /** * Get the [attribute_id] column value. * @@ -393,6 +382,17 @@ abstract class AttributeCategory implements ActiveRecordInterface return $this->attribute_id; } + /** + * Get the [template_id] column value. + * + * @return int + */ + public function getTemplateId() + { + + return $this->template_id; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -437,7 +437,7 @@ abstract class AttributeCategory implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) */ public function setId($v) { @@ -447,43 +447,18 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = AttributeCategoryTableMap::ID; + $this->modifiedColumns[] = AttributeTemplateTableMap::ID; } return $this; } // setId() - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = AttributeCategoryTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - /** * Set the value of [attribute_id] column. * * @param int $v new value - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) */ public function setAttributeId($v) { @@ -493,7 +468,7 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($this->attribute_id !== $v) { $this->attribute_id = $v; - $this->modifiedColumns[] = AttributeCategoryTableMap::ATTRIBUTE_ID; + $this->modifiedColumns[] = AttributeTemplateTableMap::ATTRIBUTE_ID; } if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { @@ -504,12 +479,37 @@ abstract class AttributeCategory implements ActiveRecordInterface return $this; } // setAttributeId() + /** + * Set the value of [template_id] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) + */ + public function setTemplateId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->template_id !== $v) { + $this->template_id = $v; + $this->modifiedColumns[] = AttributeTemplateTableMap::TEMPLATE_ID; + } + + if ($this->aTemplate !== null && $this->aTemplate->getId() !== $v) { + $this->aTemplate = null; + } + + + return $this; + } // setTemplateId() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -517,7 +517,7 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = AttributeCategoryTableMap::CREATED_AT; + $this->modifiedColumns[] = AttributeTemplateTableMap::CREATED_AT; } } // if either are not null @@ -530,7 +530,7 @@ abstract class AttributeCategory implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -538,7 +538,7 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = AttributeCategoryTableMap::UPDATED_AT; + $this->modifiedColumns[] = AttributeTemplateTableMap::UPDATED_AT; } } // if either are not null @@ -583,22 +583,22 @@ abstract class AttributeCategory implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeTemplateTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCategoryTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeTemplateTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)]; $this->attribute_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->template_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -611,10 +611,10 @@ abstract class AttributeCategory implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = AttributeTemplateTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\AttributeCategory object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\AttributeTemplate object", 0, $e); } } @@ -633,12 +633,12 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) { $this->aAttribute = null; } + if ($this->aTemplate !== null && $this->template_id !== $this->aTemplate->getId()) { + $this->aTemplate = null; + } } // ensureConsistency /** @@ -662,13 +662,13 @@ abstract class AttributeCategory implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AttributeTemplateTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildAttributeCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildAttributeTemplateQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -678,8 +678,8 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aCategory = null; $this->aAttribute = null; + $this->aTemplate = null; } // if (deep) } @@ -689,8 +689,8 @@ abstract class AttributeCategory implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see AttributeCategory::setDeleted() - * @see AttributeCategory::isDeleted() + * @see AttributeTemplate::setDeleted() + * @see AttributeTemplate::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -699,12 +699,12 @@ abstract class AttributeCategory implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildAttributeCategoryQuery::create() + $deleteQuery = ChildAttributeTemplateQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -741,7 +741,7 @@ abstract class AttributeCategory implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -751,16 +751,16 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) { + if (!$this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(AttributeTemplateTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AttributeTemplateTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -772,7 +772,7 @@ abstract class AttributeCategory implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - AttributeCategoryTableMap::addInstanceToPool($this); + AttributeTemplateTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -807,13 +807,6 @@ abstract class AttributeCategory implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - if ($this->aAttribute !== null) { if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) { $affectedRows += $this->aAttribute->save($con); @@ -821,6 +814,13 @@ abstract class AttributeCategory implements ActiveRecordInterface $this->setAttribute($this->aAttribute); } + if ($this->aTemplate !== null) { + if ($this->aTemplate->isModified() || $this->aTemplate->isNew()) { + $affectedRows += $this->aTemplate->save($con); + } + $this->setTemplate($this->aTemplate); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -852,30 +852,30 @@ abstract class AttributeCategory implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = AttributeCategoryTableMap::ID; + $this->modifiedColumns[] = AttributeTemplateTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCategoryTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeTemplateTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeCategoryTableMap::ID)) { + if ($this->isColumnModified(AttributeTemplateTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) { + if ($this->isColumnModified(AttributeTemplateTableMap::ATTRIBUTE_ID)) { $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID'; } - if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) { + if ($this->isColumnModified(AttributeTemplateTableMap::TEMPLATE_ID)) { + $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; + } + if ($this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { + if ($this->isColumnModified(AttributeTemplateTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO attribute_category (%s) VALUES (%s)', + 'INSERT INTO attribute_template (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -887,12 +887,12 @@ abstract class AttributeCategory implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; case 'ATTRIBUTE_ID': $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); break; + case 'TEMPLATE_ID': + $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -945,7 +945,7 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = AttributeCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AttributeTemplateTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -965,10 +965,10 @@ abstract class AttributeCategory implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getCategoryId(); + return $this->getAttributeId(); break; case 2: - return $this->getAttributeId(); + return $this->getTemplateId(); break; case 3: return $this->getCreatedAt(); @@ -999,15 +999,15 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['AttributeTemplate'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()] = true; - $keys = AttributeCategoryTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['AttributeTemplate'][$this->getPrimaryKey()] = true; + $keys = AttributeTemplateTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getAttributeId(), + $keys[1] => $this->getAttributeId(), + $keys[2] => $this->getTemplateId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -1018,12 +1018,12 @@ abstract class AttributeCategory implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } if (null !== $this->aAttribute) { $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aTemplate) { + $result['Template'] = $this->aTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1042,7 +1042,7 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = AttributeCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AttributeTemplateTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1062,10 +1062,10 @@ abstract class AttributeCategory implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setCategoryId($value); + $this->setAttributeId($value); break; case 2: - $this->setAttributeId($value); + $this->setTemplateId($value); break; case 3: $this->setCreatedAt($value); @@ -1095,11 +1095,11 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = AttributeCategoryTableMap::getFieldNames($keyType); + $keys = AttributeTemplateTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAttributeId($arr[$keys[2]]); + if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -1111,13 +1111,13 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(AttributeCategoryTableMap::DATABASE_NAME); + $criteria = new Criteria(AttributeTemplateTableMap::DATABASE_NAME); - if ($this->isColumnModified(AttributeCategoryTableMap::ID)) $criteria->add(AttributeCategoryTableMap::ID, $this->id); - if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) $criteria->add(AttributeCategoryTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCategoryTableMap::ATTRIBUTE_ID, $this->attribute_id); - if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) $criteria->add(AttributeCategoryTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) $criteria->add(AttributeCategoryTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(AttributeTemplateTableMap::ID)) $criteria->add(AttributeTemplateTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeTemplateTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeTemplateTableMap::ATTRIBUTE_ID, $this->attribute_id); + if ($this->isColumnModified(AttributeTemplateTableMap::TEMPLATE_ID)) $criteria->add(AttributeTemplateTableMap::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) $criteria->add(AttributeTemplateTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AttributeTemplateTableMap::UPDATED_AT)) $criteria->add(AttributeTemplateTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1132,8 +1132,8 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(AttributeCategoryTableMap::DATABASE_NAME); - $criteria->add(AttributeCategoryTableMap::ID, $this->id); + $criteria = new Criteria(AttributeTemplateTableMap::DATABASE_NAME); + $criteria->add(AttributeTemplateTableMap::ID, $this->id); return $criteria; } @@ -1174,15 +1174,15 @@ abstract class AttributeCategory implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\AttributeCategory (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\AttributeTemplate (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setCategoryId($this->getCategoryId()); $copyObj->setAttributeId($this->getAttributeId()); + $copyObj->setTemplateId($this->getTemplateId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1200,7 +1200,7 @@ abstract class AttributeCategory implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\AttributeCategory Clone of current object. + * @return \Thelia\Model\AttributeTemplate Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1213,62 +1213,11 @@ abstract class AttributeCategory implements ActiveRecordInterface return $copyObj; } - /** - * Declares an association between this object and a ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCategory($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addAttributeCategories($this); - */ - } - - return $this->aCategory; - } - /** * Declares an association between this object and a ChildAttribute object. * * @param ChildAttribute $v - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) * @throws PropelException */ public function setAttribute(ChildAttribute $v = null) @@ -1284,7 +1233,7 @@ abstract class AttributeCategory implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildAttribute object, it will not be re-added. if ($v !== null) { - $v->addAttributeCategory($this); + $v->addAttributeTemplate($this); } @@ -1308,21 +1257,72 @@ abstract class AttributeCategory implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aAttribute->addAttributeCategories($this); + $this->aAttribute->addAttributeTemplates($this); */ } return $this->aAttribute; } + /** + * Declares an association between this object and a ChildTemplate object. + * + * @param ChildTemplate $v + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) + * @throws PropelException + */ + public function setTemplate(ChildTemplate $v = null) + { + if ($v === null) { + $this->setTemplateId(NULL); + } else { + $this->setTemplateId($v->getId()); + } + + $this->aTemplate = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildTemplate object, it will not be re-added. + if ($v !== null) { + $v->addAttributeTemplate($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTemplate object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTemplate The associated ChildTemplate object. + * @throws PropelException + */ + public function getTemplate(ConnectionInterface $con = null) + { + if ($this->aTemplate === null && ($this->template_id !== null)) { + $this->aTemplate = ChildTemplateQuery::create()->findPk($this->template_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aTemplate->addAttributeTemplates($this); + */ + } + + return $this->aTemplate; + } + /** * Clears the current object and sets all attributes to their default values */ public function clear() { $this->id = null; - $this->category_id = null; $this->attribute_id = null; + $this->template_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1346,8 +1346,8 @@ abstract class AttributeCategory implements ActiveRecordInterface if ($deep) { } // if ($deep) - $this->aCategory = null; $this->aAttribute = null; + $this->aTemplate = null; } /** @@ -1357,7 +1357,7 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(AttributeCategoryTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(AttributeTemplateTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1365,11 +1365,11 @@ abstract class AttributeCategory implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildAttributeCategory The current object (for fluent API support) + * @return ChildAttributeTemplate The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = AttributeCategoryTableMap::UPDATED_AT; + $this->modifiedColumns[] = AttributeTemplateTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php b/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php similarity index 69% rename from core/lib/Thelia/Model/Base/AttributeCategoryQuery.php rename to core/lib/Thelia/Model/Base/AttributeTemplateQuery.php index d325d2037..bd895360b 100644 --- a/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php @@ -12,84 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\AttributeCategory as ChildAttributeCategory; -use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; -use Thelia\Model\Map\AttributeCategoryTableMap; +use Thelia\Model\AttributeTemplate as ChildAttributeTemplate; +use Thelia\Model\AttributeTemplateQuery as ChildAttributeTemplateQuery; +use Thelia\Model\Map\AttributeTemplateTableMap; /** - * Base class that represents a query for the 'attribute_category' table. + * Base class that represents a query for the 'attribute_template' table. * * * - * @method ChildAttributeCategoryQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildAttributeCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column - * @method ChildAttributeCategoryQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column - * @method ChildAttributeCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildAttributeCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildAttributeTemplateQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildAttributeTemplateQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column + * @method ChildAttributeTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column + * @method ChildAttributeTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ChildAttributeTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * - * @method ChildAttributeCategoryQuery groupById() Group by the id column - * @method ChildAttributeCategoryQuery groupByCategoryId() Group by the category_id column - * @method ChildAttributeCategoryQuery groupByAttributeId() Group by the attribute_id column - * @method ChildAttributeCategoryQuery groupByCreatedAt() Group by the created_at column - * @method ChildAttributeCategoryQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildAttributeTemplateQuery groupById() Group by the id column + * @method ChildAttributeTemplateQuery groupByAttributeId() Group by the attribute_id column + * @method ChildAttributeTemplateQuery groupByTemplateId() Group by the template_id column + * @method ChildAttributeTemplateQuery groupByCreatedAt() Group by the created_at column + * @method ChildAttributeTemplateQuery groupByUpdatedAt() Group by the updated_at column * - * @method ChildAttributeCategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildAttributeCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildAttributeCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildAttributeTemplateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildAttributeTemplateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildAttributeTemplateQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildAttributeCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation - * @method ChildAttributeCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation - * @method ChildAttributeCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation + * @method ChildAttributeTemplateQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation + * @method ChildAttributeTemplateQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation + * @method ChildAttributeTemplateQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation * - * @method ChildAttributeCategoryQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation - * @method ChildAttributeCategoryQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation - * @method ChildAttributeCategoryQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation + * @method ChildAttributeTemplateQuery leftJoinTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the Template relation + * @method ChildAttributeTemplateQuery rightJoinTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Template relation + * @method ChildAttributeTemplateQuery innerJoinTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the Template relation * - * @method ChildAttributeCategory findOne(ConnectionInterface $con = null) Return the first ChildAttributeCategory matching the query - * @method ChildAttributeCategory findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAttributeCategory matching the query, or a new ChildAttributeCategory object populated from the query conditions when no match is found + * @method ChildAttributeTemplate findOne(ConnectionInterface $con = null) Return the first ChildAttributeTemplate matching the query + * @method ChildAttributeTemplate findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAttributeTemplate matching the query, or a new ChildAttributeTemplate object populated from the query conditions when no match is found * - * @method ChildAttributeCategory findOneById(int $id) Return the first ChildAttributeCategory filtered by the id column - * @method ChildAttributeCategory findOneByCategoryId(int $category_id) Return the first ChildAttributeCategory filtered by the category_id column - * @method ChildAttributeCategory findOneByAttributeId(int $attribute_id) Return the first ChildAttributeCategory filtered by the attribute_id column - * @method ChildAttributeCategory findOneByCreatedAt(string $created_at) Return the first ChildAttributeCategory filtered by the created_at column - * @method ChildAttributeCategory findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeCategory filtered by the updated_at column + * @method ChildAttributeTemplate findOneById(int $id) Return the first ChildAttributeTemplate filtered by the id column + * @method ChildAttributeTemplate findOneByAttributeId(int $attribute_id) Return the first ChildAttributeTemplate filtered by the attribute_id column + * @method ChildAttributeTemplate findOneByTemplateId(int $template_id) Return the first ChildAttributeTemplate filtered by the template_id column + * @method ChildAttributeTemplate findOneByCreatedAt(string $created_at) Return the first ChildAttributeTemplate filtered by the created_at column + * @method ChildAttributeTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeTemplate filtered by the updated_at column * - * @method array findById(int $id) Return ChildAttributeCategory objects filtered by the id column - * @method array findByCategoryId(int $category_id) Return ChildAttributeCategory objects filtered by the category_id column - * @method array findByAttributeId(int $attribute_id) Return ChildAttributeCategory objects filtered by the attribute_id column - * @method array findByCreatedAt(string $created_at) Return ChildAttributeCategory objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildAttributeCategory objects filtered by the updated_at column + * @method array findById(int $id) Return ChildAttributeTemplate objects filtered by the id column + * @method array findByAttributeId(int $attribute_id) Return ChildAttributeTemplate objects filtered by the attribute_id column + * @method array findByTemplateId(int $template_id) Return ChildAttributeTemplate objects filtered by the template_id column + * @method array findByCreatedAt(string $created_at) Return ChildAttributeTemplate objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ChildAttributeTemplate objects filtered by the updated_at column * */ -abstract class AttributeCategoryQuery extends ModelCriteria +abstract class AttributeTemplateQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\AttributeCategoryQuery object. + * Initializes internal state of \Thelia\Model\Base\AttributeTemplateQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AttributeCategory', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AttributeTemplate', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildAttributeCategoryQuery object. + * Returns a new ChildAttributeTemplateQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildAttributeCategoryQuery + * @return ChildAttributeTemplateQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\AttributeCategoryQuery) { + if ($criteria instanceof \Thelia\Model\AttributeTemplateQuery) { return $criteria; } - $query = new \Thelia\Model\AttributeCategoryQuery(); + $query = new \Thelia\Model\AttributeTemplateQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -112,19 +112,19 @@ abstract class AttributeCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildAttributeCategory|array|mixed the result, formatted by the current formatter + * @return ChildAttributeTemplate|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = AttributeTemplateTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AttributeTemplateTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,11 +143,11 @@ abstract class AttributeCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildAttributeCategory A model object, or null if the key is not found + * @return ChildAttributeTemplate A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CATEGORY_ID, ATTRIBUTE_ID, CREATED_AT, UPDATED_AT FROM attribute_category WHERE ID = :p0'; + $sql = 'SELECT ID, ATTRIBUTE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM attribute_template WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -158,9 +158,9 @@ abstract class AttributeCategoryQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildAttributeCategory(); + $obj = new ChildAttributeTemplate(); $obj->hydrate($row); - AttributeCategoryTableMap::addInstanceToPool($obj, (string) $key); + AttributeTemplateTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -173,7 +173,7 @@ abstract class AttributeCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildAttributeCategory|array|mixed the result, formatted by the current formatter + * @return ChildAttributeTemplate|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -215,12 +215,12 @@ abstract class AttributeCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AttributeCategoryTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AttributeTemplateTableMap::ID, $key, Criteria::EQUAL); } /** @@ -228,12 +228,12 @@ abstract class AttributeCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AttributeCategoryTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AttributeTemplateTableMap::ID, $keys, Criteria::IN); } /** @@ -252,18 +252,18 @@ abstract class AttributeCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -274,50 +274,7 @@ abstract class AttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(AttributeTemplateTableMap::ID, $id, $comparison); } /** @@ -338,18 +295,18 @@ abstract class AttributeCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterByAttributeId($attributeId = null, $comparison = null) { if (is_array($attributeId)) { $useMinMax = false; if (isset($attributeId['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -360,7 +317,50 @@ abstract class AttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId, $comparison); + return $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attributeId, $comparison); + } + + /** + * Filter the query on the template_id column + * + * Example usage: + * + * $query->filterByTemplateId(1234); // WHERE template_id = 1234 + * $query->filterByTemplateId(array(12, 34)); // WHERE template_id IN (12, 34) + * $query->filterByTemplateId(array('min' => 12)); // WHERE template_id > 12 + * + * + * @see filterByTemplate() + * + * @param mixed $templateId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAttributeTemplateQuery The current query, for fluid interface + */ + public function filterByTemplateId($templateId = null, $comparison = null) + { + if (is_array($templateId)) { + $useMinMax = false; + if (isset($templateId['min'])) { + $this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($templateId['max'])) { + $this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId, $comparison); } /** @@ -381,18 +381,18 @@ abstract class AttributeCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterByCreatedAt($createdAt = null, $comparison = null) { if (is_array($createdAt)) { $useMinMax = false; if (isset($createdAt['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -403,7 +403,7 @@ abstract class AttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AttributeTemplateTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -424,18 +424,18 @@ abstract class AttributeCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterByUpdatedAt($updatedAt = null, $comparison = null) { if (is_array($updatedAt)) { $useMinMax = false; if (isset($updatedAt['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -446,82 +446,7 @@ abstract class AttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + return $this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -530,20 +455,20 @@ abstract class AttributeCategoryQuery extends ModelCriteria * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function filterByAttribute($attribute, $comparison = null) { if ($attribute instanceof \Thelia\Model\Attribute) { return $this - ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); + ->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); } elseif ($attribute instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); } @@ -555,7 +480,7 @@ abstract class AttributeCategoryQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -600,23 +525,98 @@ abstract class AttributeCategoryQuery extends ModelCriteria } /** - * Exclude object from result + * Filter the query by a related \Thelia\Model\Template object * - * @param ChildAttributeCategory $attributeCategory Object to remove from the list of results + * @param \Thelia\Model\Template|ObjectCollection $template The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ - public function prune($attributeCategory = null) + public function filterByTemplate($template, $comparison = null) { - if ($attributeCategory) { - $this->addUsingAlias(AttributeCategoryTableMap::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL); + if ($template instanceof \Thelia\Model\Template) { + return $this + ->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $template->getId(), $comparison); + } elseif ($template instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $template->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByTemplate() only accepts arguments of type \Thelia\Model\Template or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Template relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAttributeTemplateQuery The current query, for fluid interface + */ + public function joinTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Template'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Template'); } return $this; } /** - * Deletes all rows from the attribute_category table. + * Use the Template relation Template object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query + */ + public function useTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Template', '\Thelia\Model\TemplateQuery'); + } + + /** + * Exclude object from result + * + * @param ChildAttributeTemplate $attributeTemplate Object to remove from the list of results + * + * @return ChildAttributeTemplateQuery The current query, for fluid interface + */ + public function prune($attributeTemplate = null) + { + if ($attributeTemplate) { + $this->addUsingAlias(AttributeTemplateTableMap::ID, $attributeTemplate->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the attribute_template table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -624,7 +624,7 @@ abstract class AttributeCategoryQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -635,8 +635,8 @@ abstract class AttributeCategoryQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - AttributeCategoryTableMap::clearInstancePool(); - AttributeCategoryTableMap::clearRelatedInstancePool(); + AttributeTemplateTableMap::clearInstancePool(); + AttributeTemplateTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -648,9 +648,9 @@ abstract class AttributeCategoryQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildAttributeCategory or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildAttributeTemplate or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildAttributeCategory object or primary key or array of primary keys + * @param mixed $values Criteria or ChildAttributeTemplate object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -661,13 +661,13 @@ abstract class AttributeCategoryQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(AttributeCategoryTableMap::DATABASE_NAME); + $criteria->setDbName(AttributeTemplateTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -677,10 +677,10 @@ abstract class AttributeCategoryQuery extends ModelCriteria $con->beginTransaction(); - AttributeCategoryTableMap::removeInstanceFromPool($criteria); + AttributeTemplateTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - AttributeCategoryTableMap::clearRelatedInstancePool(); + AttributeTemplateTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -697,11 +697,11 @@ abstract class AttributeCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function recentlyUpdated($nbDays = 7) { - return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -709,51 +709,51 @@ abstract class AttributeCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function recentlyCreated($nbDays = 7) { - return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AttributeTemplateTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(AttributeTemplateTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(AttributeTemplateTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(AttributeTemplateTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildAttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeTemplateQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(AttributeTemplateTableMap::CREATED_AT); } -} // AttributeCategoryQuery +} // AttributeTemplateQuery diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index 5dd573d39..e785ae0a5 100644 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -116,6 +116,12 @@ abstract class CartItem implements ActiveRecordInterface */ protected $discount; + /** + * The value for the promo field. + * @var int + */ + protected $promo; + /** * The value for the created_at field. * @var string @@ -527,6 +533,17 @@ abstract class CartItem implements ActiveRecordInterface return $this->discount; } + /** + * Get the [promo] column value. + * + * @return int + */ + public function getPromo() + { + + return $this->promo; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -768,6 +785,27 @@ abstract class CartItem implements ActiveRecordInterface return $this; } // setDiscount() + /** + * Set the value of [promo] column. + * + * @param int $v new value + * @return \Thelia\Model\CartItem The current object (for fluent API support) + */ + public function setPromo($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->promo !== $v) { + $this->promo = $v; + $this->modifiedColumns[] = CartItemTableMap::PROMO; + } + + + return $this; + } // setPromo() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -885,13 +923,16 @@ abstract class CartItem implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; $this->discount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -904,7 +945,7 @@ abstract class CartItem implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 11; // 11 = CartItemTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 12; // 12 = CartItemTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\CartItem object", 0, $e); @@ -1189,6 +1230,9 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) { $modifiedColumns[':p' . $index++] = 'DISCOUNT'; } + if ($this->isColumnModified(CartItemTableMap::PROMO)) { + $modifiedColumns[':p' . $index++] = 'PROMO'; + } if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1233,6 +1277,9 @@ abstract class CartItem implements ActiveRecordInterface case 'DISCOUNT': $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); break; + case 'PROMO': + $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1329,9 +1376,12 @@ abstract class CartItem implements ActiveRecordInterface return $this->getDiscount(); break; case 9: - return $this->getCreatedAt(); + return $this->getPromo(); break; case 10: + return $this->getCreatedAt(); + break; + case 11: return $this->getUpdatedAt(); break; default: @@ -1372,8 +1422,9 @@ abstract class CartItem implements ActiveRecordInterface $keys[6] => $this->getPromoPrice(), $keys[7] => $this->getPriceEndOfLife(), $keys[8] => $this->getDiscount(), - $keys[9] => $this->getCreatedAt(), - $keys[10] => $this->getUpdatedAt(), + $keys[9] => $this->getPromo(), + $keys[10] => $this->getCreatedAt(), + $keys[11] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1453,9 +1504,12 @@ abstract class CartItem implements ActiveRecordInterface $this->setDiscount($value); break; case 9: - $this->setCreatedAt($value); + $this->setPromo($value); break; case 10: + $this->setCreatedAt($value); + break; + case 11: $this->setUpdatedAt($value); break; } // switch() @@ -1491,8 +1545,9 @@ abstract class CartItem implements ActiveRecordInterface if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setPriceEndOfLife($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]); + if (array_key_exists($keys[9], $arr)) $this->setPromo($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); } /** @@ -1513,6 +1568,7 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price); if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) $criteria->add(CartItemTableMap::PRICE_END_OF_LIFE, $this->price_end_of_life); if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) $criteria->add(CartItemTableMap::DISCOUNT, $this->discount); + if ($this->isColumnModified(CartItemTableMap::PROMO)) $criteria->add(CartItemTableMap::PROMO, $this->promo); if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) $criteria->add(CartItemTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CartItemTableMap::UPDATED_AT)) $criteria->add(CartItemTableMap::UPDATED_AT, $this->updated_at); @@ -1586,6 +1642,7 @@ abstract class CartItem implements ActiveRecordInterface $copyObj->setPromoPrice($this->getPromoPrice()); $copyObj->setPriceEndOfLife($this->getPriceEndOfLife()); $copyObj->setDiscount($this->getDiscount()); + $copyObj->setPromo($this->getPromo()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1783,6 +1840,7 @@ abstract class CartItem implements ActiveRecordInterface $this->promo_price = null; $this->price_end_of_life = null; $this->discount = null; + $this->promo = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/CartItemQuery.php b/core/lib/Thelia/Model/Base/CartItemQuery.php index 83705aeac..79d5d3cfe 100644 --- a/core/lib/Thelia/Model/Base/CartItemQuery.php +++ b/core/lib/Thelia/Model/Base/CartItemQuery.php @@ -30,6 +30,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column * @method ChildCartItemQuery orderByPriceEndOfLife($order = Criteria::ASC) Order by the price_end_of_life column * @method ChildCartItemQuery orderByDiscount($order = Criteria::ASC) Order by the discount column + * @method ChildCartItemQuery orderByPromo($order = Criteria::ASC) Order by the promo column * @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -42,6 +43,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column * @method ChildCartItemQuery groupByPriceEndOfLife() Group by the price_end_of_life column * @method ChildCartItemQuery groupByDiscount() Group by the discount column + * @method ChildCartItemQuery groupByPromo() Group by the promo column * @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column * @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column * @@ -73,6 +75,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column * @method ChildCartItem findOneByPriceEndOfLife(string $price_end_of_life) Return the first ChildCartItem filtered by the price_end_of_life column * @method ChildCartItem findOneByDiscount(double $discount) Return the first ChildCartItem filtered by the discount column + * @method ChildCartItem findOneByPromo(int $promo) Return the first ChildCartItem filtered by the promo column * @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column * @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column * @@ -85,6 +88,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column * @method array findByPriceEndOfLife(string $price_end_of_life) Return ChildCartItem objects filtered by the price_end_of_life column * @method array findByDiscount(double $discount) Return ChildCartItem objects filtered by the discount column + * @method array findByPromo(int $promo) Return ChildCartItem objects filtered by the promo column * @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column * @@ -175,7 +179,7 @@ abstract class CartItemQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; + $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, PROMO, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -641,6 +645,47 @@ abstract class CartItemQuery extends ModelCriteria return $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount, $comparison); } + /** + * Filter the query on the promo column + * + * Example usage: + * + * $query->filterByPromo(1234); // WHERE promo = 1234 + * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34) + * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12 + * + * + * @param mixed $promo The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCartItemQuery The current query, for fluid interface + */ + public function filterByPromo($promo = null, $comparison = null) + { + if (is_array($promo)) { + $useMinMax = false; + if (isset($promo['min'])) { + $this->addUsingAlias(CartItemTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($promo['max'])) { + $this->addUsingAlias(CartItemTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CartItemTableMap::PROMO, $promo, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index ee56670a1..6dc9b727a 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -17,10 +17,6 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Attribute as ChildAttribute; -use Thelia\Model\AttributeCategory as ChildAttributeCategory; -use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; -use Thelia\Model\AttributeQuery as ChildAttributeQuery; use Thelia\Model\Category as ChildCategory; use Thelia\Model\CategoryAssociatedContent as ChildCategoryAssociatedContent; use Thelia\Model\CategoryAssociatedContentQuery as ChildCategoryAssociatedContentQuery; @@ -33,10 +29,6 @@ use Thelia\Model\CategoryImageQuery as ChildCategoryImageQuery; use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\CategoryVersion as ChildCategoryVersion; use Thelia\Model\CategoryVersionQuery as ChildCategoryVersionQuery; -use Thelia\Model\Feature as ChildFeature; -use Thelia\Model\FeatureCategory as ChildFeatureCategory; -use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; -use Thelia\Model\FeatureQuery as ChildFeatureQuery; use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductCategory as ChildProductCategory; use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; @@ -139,18 +131,6 @@ abstract class Category implements ActiveRecordInterface protected $collProductCategories; protected $collProductCategoriesPartial; - /** - * @var ObjectCollection|ChildFeatureCategory[] Collection to store aggregation of ChildFeatureCategory objects. - */ - protected $collFeatureCategories; - protected $collFeatureCategoriesPartial; - - /** - * @var ObjectCollection|ChildAttributeCategory[] Collection to store aggregation of ChildAttributeCategory objects. - */ - protected $collAttributeCategories; - protected $collAttributeCategoriesPartial; - /** * @var ObjectCollection|ChildCategoryImage[] Collection to store aggregation of ChildCategoryImage objects. */ @@ -186,16 +166,6 @@ abstract class Category implements ActiveRecordInterface */ protected $collProducts; - /** - * @var ChildFeature[] Collection to store aggregation of ChildFeature objects. - */ - protected $collFeatures; - - /** - * @var ChildAttribute[] Collection to store aggregation of ChildAttribute objects. - */ - protected $collAttributes; - /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -232,36 +202,12 @@ abstract class Category implements ActiveRecordInterface */ protected $productsScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $featuresScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $attributesScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection */ protected $productCategoriesScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $featureCategoriesScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $attributeCategoriesScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1021,10 +967,6 @@ abstract class Category implements ActiveRecordInterface $this->collProductCategories = null; - $this->collFeatureCategories = null; - - $this->collAttributeCategories = null; - $this->collCategoryImages = null; $this->collCategoryDocuments = null; @@ -1036,8 +978,6 @@ abstract class Category implements ActiveRecordInterface $this->collCategoryVersions = null; $this->collProducts = null; - $this->collFeatures = null; - $this->collAttributes = null; } // if (deep) } @@ -1210,60 +1150,6 @@ abstract class Category implements ActiveRecordInterface } } - if ($this->featuresScheduledForDeletion !== null) { - if (!$this->featuresScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->featuresScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->featuresScheduledForDeletion = null; - } - - foreach ($this->getFeatures() as $feature) { - if ($feature->isModified()) { - $feature->save($con); - } - } - } elseif ($this->collFeatures) { - foreach ($this->collFeatures as $feature) { - if ($feature->isModified()) { - $feature->save($con); - } - } - } - - if ($this->attributesScheduledForDeletion !== null) { - if (!$this->attributesScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->attributesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->attributesScheduledForDeletion = null; - } - - foreach ($this->getAttributes() as $attribute) { - if ($attribute->isModified()) { - $attribute->save($con); - } - } - } elseif ($this->collAttributes) { - foreach ($this->collAttributes as $attribute) { - if ($attribute->isModified()) { - $attribute->save($con); - } - } - } - if ($this->productCategoriesScheduledForDeletion !== null) { if (!$this->productCategoriesScheduledForDeletion->isEmpty()) { \Thelia\Model\ProductCategoryQuery::create() @@ -1281,40 +1167,6 @@ abstract class Category implements ActiveRecordInterface } } - if ($this->featureCategoriesScheduledForDeletion !== null) { - if (!$this->featureCategoriesScheduledForDeletion->isEmpty()) { - \Thelia\Model\FeatureCategoryQuery::create() - ->filterByPrimaryKeys($this->featureCategoriesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureCategoriesScheduledForDeletion = null; - } - } - - if ($this->collFeatureCategories !== null) { - foreach ($this->collFeatureCategories as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->attributeCategoriesScheduledForDeletion !== null) { - if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) { - \Thelia\Model\AttributeCategoryQuery::create() - ->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCategoriesScheduledForDeletion = null; - } - } - - if ($this->collAttributeCategories !== null) { - foreach ($this->collAttributeCategories as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->categoryImagesScheduledForDeletion !== null) { if (!$this->categoryImagesScheduledForDeletion->isEmpty()) { \Thelia\Model\CategoryImageQuery::create() @@ -1629,12 +1481,6 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collProductCategories) { $result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collFeatureCategories) { - $result['FeatureCategories'] = $this->collFeatureCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAttributeCategories) { - $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collCategoryImages) { $result['CategoryImages'] = $this->collCategoryImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1847,18 +1693,6 @@ abstract class Category implements ActiveRecordInterface } } - foreach ($this->getFeatureCategories() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAttributeCategories() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCategory($relObj->copy($deepCopy)); - } - } - foreach ($this->getCategoryImages() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCategoryImage($relObj->copy($deepCopy)); @@ -1933,12 +1767,6 @@ abstract class Category implements ActiveRecordInterface if ('ProductCategory' == $relationName) { return $this->initProductCategories(); } - if ('FeatureCategory' == $relationName) { - return $this->initFeatureCategories(); - } - if ('AttributeCategory' == $relationName) { - return $this->initAttributeCategories(); - } if ('CategoryImage' == $relationName) { return $this->initCategoryImages(); } @@ -2202,492 +2030,6 @@ abstract class Category implements ActiveRecordInterface return $this->getProductCategories($query, $con); } - /** - * Clears out the collFeatureCategories collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addFeatureCategories() - */ - public function clearFeatureCategories() - { - $this->collFeatureCategories = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collFeatureCategories collection loaded partially. - */ - public function resetPartialFeatureCategories($v = true) - { - $this->collFeatureCategoriesPartial = $v; - } - - /** - * Initializes the collFeatureCategories collection. - * - * By default this just sets the collFeatureCategories collection to an empty array (like clearcollFeatureCategories()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureCategories($overrideExisting = true) - { - if (null !== $this->collFeatureCategories && !$overrideExisting) { - return; - } - $this->collFeatureCategories = new ObjectCollection(); - $this->collFeatureCategories->setModel('\Thelia\Model\FeatureCategory'); - } - - /** - * Gets an array of ChildFeatureCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects - * @throws PropelException - */ - public function getFeatureCategories($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); - if (null === $this->collFeatureCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategories) { - // return empty collection - $this->initFeatureCategories(); - } else { - $collFeatureCategories = ChildFeatureCategoryQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collFeatureCategoriesPartial && count($collFeatureCategories)) { - $this->initFeatureCategories(false); - - foreach ($collFeatureCategories as $obj) { - if (false == $this->collFeatureCategories->contains($obj)) { - $this->collFeatureCategories->append($obj); - } - } - - $this->collFeatureCategoriesPartial = true; - } - - $collFeatureCategories->getInternalIterator()->rewind(); - - return $collFeatureCategories; - } - - if ($partial && $this->collFeatureCategories) { - foreach ($this->collFeatureCategories as $obj) { - if ($obj->isNew()) { - $collFeatureCategories[] = $obj; - } - } - } - - $this->collFeatureCategories = $collFeatureCategories; - $this->collFeatureCategoriesPartial = false; - } - } - - return $this->collFeatureCategories; - } - - /** - * Sets a collection of FeatureCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $featureCategories A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setFeatureCategories(Collection $featureCategories, ConnectionInterface $con = null) - { - $featureCategoriesToDelete = $this->getFeatureCategories(new Criteria(), $con)->diff($featureCategories); - - - $this->featureCategoriesScheduledForDeletion = $featureCategoriesToDelete; - - foreach ($featureCategoriesToDelete as $featureCategoryRemoved) { - $featureCategoryRemoved->setCategory(null); - } - - $this->collFeatureCategories = null; - foreach ($featureCategories as $featureCategory) { - $this->addFeatureCategory($featureCategory); - } - - $this->collFeatureCategories = $featureCategories; - $this->collFeatureCategoriesPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related FeatureCategory objects. - * @throws PropelException - */ - public function countFeatureCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); - if (null === $this->collFeatureCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategories) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getFeatureCategories()); - } - - $query = ChildFeatureCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collFeatureCategories); - } - - /** - * Method called to associate a ChildFeatureCategory object to this object - * through the ChildFeatureCategory foreign key attribute. - * - * @param ChildFeatureCategory $l ChildFeatureCategory - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addFeatureCategory(ChildFeatureCategory $l) - { - if ($this->collFeatureCategories === null) { - $this->initFeatureCategories(); - $this->collFeatureCategoriesPartial = true; - } - - if (!in_array($l, $this->collFeatureCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureCategory($l); - } - - return $this; - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to add. - */ - protected function doAddFeatureCategory($featureCategory) - { - $this->collFeatureCategories[]= $featureCategory; - $featureCategory->setCategory($this); - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeFeatureCategory($featureCategory) - { - if ($this->getFeatureCategories()->contains($featureCategory)) { - $this->collFeatureCategories->remove($this->collFeatureCategories->search($featureCategory)); - if (null === $this->featureCategoriesScheduledForDeletion) { - $this->featureCategoriesScheduledForDeletion = clone $this->collFeatureCategories; - $this->featureCategoriesScheduledForDeletion->clear(); - } - $this->featureCategoriesScheduledForDeletion[]= clone $featureCategory; - $featureCategory->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related FeatureCategories from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects - */ - public function getFeatureCategoriesJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildFeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Feature', $joinBehavior); - - return $this->getFeatureCategories($query, $con); - } - - /** - * Clears out the collAttributeCategories collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addAttributeCategories() - */ - public function clearAttributeCategories() - { - $this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collAttributeCategories collection loaded partially. - */ - public function resetPartialAttributeCategories($v = true) - { - $this->collAttributeCategoriesPartial = $v; - } - - /** - * Initializes the collAttributeCategories collection. - * - * By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCategories($overrideExisting = true) - { - if (null !== $this->collAttributeCategories && !$overrideExisting) { - return; - } - $this->collAttributeCategories = new ObjectCollection(); - $this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory'); - } - - /** - * Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects - * @throws PropelException - */ - public function getAttributeCategories($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); - if (null === $this->collAttributeCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategories) { - // return empty collection - $this->initAttributeCategories(); - } else { - $collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) { - $this->initAttributeCategories(false); - - foreach ($collAttributeCategories as $obj) { - if (false == $this->collAttributeCategories->contains($obj)) { - $this->collAttributeCategories->append($obj); - } - } - - $this->collAttributeCategoriesPartial = true; - } - - $collAttributeCategories->getInternalIterator()->rewind(); - - return $collAttributeCategories; - } - - if ($partial && $this->collAttributeCategories) { - foreach ($this->collAttributeCategories as $obj) { - if ($obj->isNew()) { - $collAttributeCategories[] = $obj; - } - } - } - - $this->collAttributeCategories = $collAttributeCategories; - $this->collAttributeCategoriesPartial = false; - } - } - - return $this->collAttributeCategories; - } - - /** - * Sets a collection of AttributeCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $attributeCategories A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null) - { - $attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories); - - - $this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete; - - foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) { - $attributeCategoryRemoved->setCategory(null); - } - - $this->collAttributeCategories = null; - foreach ($attributeCategories as $attributeCategory) { - $this->addAttributeCategory($attributeCategory); - } - - $this->collAttributeCategories = $attributeCategories; - $this->collAttributeCategoriesPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related AttributeCategory objects. - * @throws PropelException - */ - public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); - if (null === $this->collAttributeCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategories) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getAttributeCategories()); - } - - $query = ChildAttributeCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collAttributeCategories); - } - - /** - * Method called to associate a ChildAttributeCategory object to this object - * through the ChildAttributeCategory foreign key attribute. - * - * @param ChildAttributeCategory $l ChildAttributeCategory - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addAttributeCategory(ChildAttributeCategory $l) - { - if ($this->collAttributeCategories === null) { - $this->initAttributeCategories(); - $this->collAttributeCategoriesPartial = true; - } - - if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCategory($l); - } - - return $this; - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. - */ - protected function doAddAttributeCategory($attributeCategory) - { - $this->collAttributeCategories[]= $attributeCategory; - $attributeCategory->setCategory($this); - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeAttributeCategory($attributeCategory) - { - if ($this->getAttributeCategories()->contains($attributeCategory)) { - $this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory)); - if (null === $this->attributeCategoriesScheduledForDeletion) { - $this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories; - $this->attributeCategoriesScheduledForDeletion->clear(); - } - $this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory; - $attributeCategory->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related AttributeCategories from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects - */ - public function getAttributeCategoriesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildAttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Attribute', $joinBehavior); - - return $this->getAttributeCategories($query, $con); - } - /** * Clears out the collCategoryImages collection * @@ -3996,372 +3338,6 @@ abstract class Category implements ActiveRecordInterface return $this; } - /** - * Clears out the collFeatures collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addFeatures() - */ - public function clearFeatures() - { - $this->collFeatures = null; // important to set this to NULL since that means it is uninitialized - $this->collFeaturesPartial = null; - } - - /** - * Initializes the collFeatures collection. - * - * By default this just sets the collFeatures collection to an empty collection (like clearFeatures()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @return void - */ - public function initFeatures() - { - $this->collFeatures = new ObjectCollection(); - $this->collFeatures->setModel('\Thelia\Model\Feature'); - } - - /** - * Gets a collection of ChildFeature objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param ConnectionInterface $con Optional connection object - * - * @return ObjectCollection|ChildFeature[] List of ChildFeature objects - */ - public function getFeatures($criteria = null, ConnectionInterface $con = null) - { - if (null === $this->collFeatures || null !== $criteria) { - if ($this->isNew() && null === $this->collFeatures) { - // return empty collection - $this->initFeatures(); - } else { - $collFeatures = ChildFeatureQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - return $collFeatures; - } - $this->collFeatures = $collFeatures; - } - } - - return $this->collFeatures; - } - - /** - * Sets a collection of Feature objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $features A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setFeatures(Collection $features, ConnectionInterface $con = null) - { - $this->clearFeatures(); - $currentFeatures = $this->getFeatures(); - - $this->featuresScheduledForDeletion = $currentFeatures->diff($features); - - foreach ($features as $feature) { - if (!$currentFeatures->contains($feature)) { - $this->doAddFeature($feature); - } - } - - $this->collFeatures = $features; - - return $this; - } - - /** - * Gets the number of ChildFeature objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param ConnectionInterface $con Optional connection object - * - * @return int the number of related ChildFeature objects - */ - public function countFeatures($criteria = null, $distinct = false, ConnectionInterface $con = null) - { - if (null === $this->collFeatures || null !== $criteria) { - if ($this->isNew() && null === $this->collFeatures) { - return 0; - } else { - $query = ChildFeatureQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - } else { - return count($this->collFeatures); - } - } - - /** - * Associate a ChildFeature object to this object - * through the feature_category cross reference table. - * - * @param ChildFeature $feature The ChildFeatureCategory object to relate - * @return ChildCategory The current object (for fluent API support) - */ - public function addFeature(ChildFeature $feature) - { - if ($this->collFeatures === null) { - $this->initFeatures(); - } - - if (!$this->collFeatures->contains($feature)) { // only add it if the **same** object is not already associated - $this->doAddFeature($feature); - $this->collFeatures[] = $feature; - } - - return $this; - } - - /** - * @param Feature $feature The feature object to add. - */ - protected function doAddFeature($feature) - { - $featureCategory = new ChildFeatureCategory(); - $featureCategory->setFeature($feature); - $this->addFeatureCategory($featureCategory); - // set the back reference to this object directly as using provided method either results - // in endless loop or in multiple relations - if (!$feature->getCategories()->contains($this)) { - $foreignCollection = $feature->getCategories(); - $foreignCollection[] = $this; - } - } - - /** - * Remove a ChildFeature object to this object - * through the feature_category cross reference table. - * - * @param ChildFeature $feature The ChildFeatureCategory object to relate - * @return ChildCategory The current object (for fluent API support) - */ - public function removeFeature(ChildFeature $feature) - { - if ($this->getFeatures()->contains($feature)) { - $this->collFeatures->remove($this->collFeatures->search($feature)); - - if (null === $this->featuresScheduledForDeletion) { - $this->featuresScheduledForDeletion = clone $this->collFeatures; - $this->featuresScheduledForDeletion->clear(); - } - - $this->featuresScheduledForDeletion[] = $feature; - } - - return $this; - } - - /** - * Clears out the collAttributes collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addAttributes() - */ - public function clearAttributes() - { - $this->collAttributes = null; // important to set this to NULL since that means it is uninitialized - $this->collAttributesPartial = null; - } - - /** - * Initializes the collAttributes collection. - * - * By default this just sets the collAttributes collection to an empty collection (like clearAttributes()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @return void - */ - public function initAttributes() - { - $this->collAttributes = new ObjectCollection(); - $this->collAttributes->setModel('\Thelia\Model\Attribute'); - } - - /** - * Gets a collection of ChildAttribute objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param ConnectionInterface $con Optional connection object - * - * @return ObjectCollection|ChildAttribute[] List of ChildAttribute objects - */ - public function getAttributes($criteria = null, ConnectionInterface $con = null) - { - if (null === $this->collAttributes || null !== $criteria) { - if ($this->isNew() && null === $this->collAttributes) { - // return empty collection - $this->initAttributes(); - } else { - $collAttributes = ChildAttributeQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - return $collAttributes; - } - $this->collAttributes = $collAttributes; - } - } - - return $this->collAttributes; - } - - /** - * Sets a collection of Attribute objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $attributes A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setAttributes(Collection $attributes, ConnectionInterface $con = null) - { - $this->clearAttributes(); - $currentAttributes = $this->getAttributes(); - - $this->attributesScheduledForDeletion = $currentAttributes->diff($attributes); - - foreach ($attributes as $attribute) { - if (!$currentAttributes->contains($attribute)) { - $this->doAddAttribute($attribute); - } - } - - $this->collAttributes = $attributes; - - return $this; - } - - /** - * Gets the number of ChildAttribute objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param ConnectionInterface $con Optional connection object - * - * @return int the number of related ChildAttribute objects - */ - public function countAttributes($criteria = null, $distinct = false, ConnectionInterface $con = null) - { - if (null === $this->collAttributes || null !== $criteria) { - if ($this->isNew() && null === $this->collAttributes) { - return 0; - } else { - $query = ChildAttributeQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - } else { - return count($this->collAttributes); - } - } - - /** - * Associate a ChildAttribute object to this object - * through the attribute_category cross reference table. - * - * @param ChildAttribute $attribute The ChildAttributeCategory object to relate - * @return ChildCategory The current object (for fluent API support) - */ - public function addAttribute(ChildAttribute $attribute) - { - if ($this->collAttributes === null) { - $this->initAttributes(); - } - - if (!$this->collAttributes->contains($attribute)) { // only add it if the **same** object is not already associated - $this->doAddAttribute($attribute); - $this->collAttributes[] = $attribute; - } - - return $this; - } - - /** - * @param Attribute $attribute The attribute object to add. - */ - protected function doAddAttribute($attribute) - { - $attributeCategory = new ChildAttributeCategory(); - $attributeCategory->setAttribute($attribute); - $this->addAttributeCategory($attributeCategory); - // set the back reference to this object directly as using provided method either results - // in endless loop or in multiple relations - if (!$attribute->getCategories()->contains($this)) { - $foreignCollection = $attribute->getCategories(); - $foreignCollection[] = $this; - } - } - - /** - * Remove a ChildAttribute object to this object - * through the attribute_category cross reference table. - * - * @param ChildAttribute $attribute The ChildAttributeCategory object to relate - * @return ChildCategory The current object (for fluent API support) - */ - public function removeAttribute(ChildAttribute $attribute) - { - if ($this->getAttributes()->contains($attribute)) { - $this->collAttributes->remove($this->collAttributes->search($attribute)); - - if (null === $this->attributesScheduledForDeletion) { - $this->attributesScheduledForDeletion = clone $this->collAttributes; - $this->attributesScheduledForDeletion->clear(); - } - - $this->attributesScheduledForDeletion[] = $attribute; - } - - return $this; - } - /** * Clears the current object and sets all attributes to their default values */ @@ -4401,16 +3377,6 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collFeatureCategories) { - foreach ($this->collFeatureCategories as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributeCategories) { - foreach ($this->collAttributeCategories as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collCategoryImages) { foreach ($this->collCategoryImages as $o) { $o->clearAllReferences($deep); @@ -4441,16 +3407,6 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collFeatures) { - foreach ($this->collFeatures as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributes) { - foreach ($this->collAttributes as $o) { - $o->clearAllReferences($deep); - } - } } // if ($deep) // i18n behavior @@ -4461,14 +3417,6 @@ abstract class Category implements ActiveRecordInterface $this->collProductCategories->clearIterator(); } $this->collProductCategories = null; - if ($this->collFeatureCategories instanceof Collection) { - $this->collFeatureCategories->clearIterator(); - } - $this->collFeatureCategories = null; - if ($this->collAttributeCategories instanceof Collection) { - $this->collAttributeCategories->clearIterator(); - } - $this->collAttributeCategories = null; if ($this->collCategoryImages instanceof Collection) { $this->collCategoryImages->clearIterator(); } @@ -4493,14 +3441,6 @@ abstract class Category implements ActiveRecordInterface $this->collProducts->clearIterator(); } $this->collProducts = null; - if ($this->collFeatures instanceof Collection) { - $this->collFeatures->clearIterator(); - } - $this->collFeatures = null; - if ($this->collAttributes instanceof Collection) { - $this->collAttributes->clearIterator(); - } - $this->collAttributes = null; } /** diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index 7f0fb8f1c..4ef552094 100644 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -50,14 +50,6 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation * @method ChildCategoryQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation * - * @method ChildCategoryQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation - * @method ChildCategoryQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation - * @method ChildCategoryQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation - * - * @method ChildCategoryQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation - * @method ChildCategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation - * @method ChildCategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation - * * @method ChildCategoryQuery leftJoinCategoryImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryImage relation * @method ChildCategoryQuery rightJoinCategoryImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryImage relation * @method ChildCategoryQuery innerJoinCategoryImage($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryImage relation @@ -720,152 +712,6 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); } - /** - * Filter the query by a related \Thelia\Model\FeatureCategory object - * - * @param \Thelia\Model\FeatureCategory|ObjectCollection $featureCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByFeatureCategory($featureCategory, $comparison = null) - { - if ($featureCategory instanceof \Thelia\Model\FeatureCategory) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $featureCategory->getCategoryId(), $comparison); - } elseif ($featureCategory instanceof ObjectCollection) { - return $this - ->useFeatureCategoryQuery() - ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureCategory'); - } - - return $this; - } - - /** - * Use the FeatureCategory relation FeatureCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query - */ - public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\AttributeCategory object - * - * @param \Thelia\Model\AttributeCategory|ObjectCollection $attributeCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByAttributeCategory($attributeCategory, $comparison = null) - { - if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $attributeCategory->getCategoryId(), $comparison); - } elseif ($attributeCategory instanceof ObjectCollection) { - return $this - ->useAttributeCategoryQuery() - ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCategory'); - } - - return $this; - } - - /** - * Use the AttributeCategory relation AttributeCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query - */ - public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); - } - /** * Filter the query by a related \Thelia\Model\CategoryImage object * @@ -1248,40 +1094,6 @@ abstract class CategoryQuery extends ModelCriteria ->endUse(); } - /** - * Filter the query by a related Feature object - * using the feature_category table as cross reference - * - * @param Feature $feature the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByFeature($feature, $comparison = Criteria::EQUAL) - { - return $this - ->useFeatureCategoryQuery() - ->filterByFeature($feature, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Attribute object - * using the attribute_category table as cross reference - * - * @param Attribute $attribute the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByAttribute($attribute, $comparison = Criteria::EQUAL) - { - return $this - ->useAttributeCategoryQuery() - ->filterByAttribute($attribute, $comparison) - ->endUse(); - } - /** * Exclude object from result * diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php index 51d72b974..809825d51 100644 --- a/core/lib/Thelia/Model/Base/ContentFolder.php +++ b/core/lib/Thelia/Model/Base/ContentFolder.php @@ -70,6 +70,12 @@ abstract class ContentFolder implements ActiveRecordInterface */ protected $folder_id; + /** + * The value for the default_folder field. + * @var boolean + */ + protected $default_folder; + /** * The value for the created_at field. * @var string @@ -376,6 +382,17 @@ abstract class ContentFolder implements ActiveRecordInterface return $this->folder_id; } + /** + * Get the [default_folder] column value. + * + * @return boolean + */ + public function getDefaultFolder() + { + + return $this->default_folder; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -466,6 +483,35 @@ abstract class ContentFolder implements ActiveRecordInterface return $this; } // setFolderId() + /** + * Sets the value of the [default_folder] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\ContentFolder The current object (for fluent API support) + */ + public function setDefaultFolder($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->default_folder !== $v) { + $this->default_folder = $v; + $this->modifiedColumns[] = ContentFolderTableMap::DEFAULT_FOLDER; + } + + + return $this; + } // setDefaultFolder() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -551,13 +597,16 @@ abstract class ContentFolder implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentFolderTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; $this->folder_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentFolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentFolderTableMap::translateFieldName('DefaultFolder', TableMap::TYPE_PHPNAME, $indexType)]; + $this->default_folder = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentFolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentFolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentFolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -570,7 +619,7 @@ abstract class ContentFolder implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 4; // 4 = ContentFolderTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = ContentFolderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ContentFolder object", 0, $e); @@ -819,6 +868,9 @@ abstract class ContentFolder implements ActiveRecordInterface if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) { $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; } + if ($this->isColumnModified(ContentFolderTableMap::DEFAULT_FOLDER)) { + $modifiedColumns[':p' . $index++] = 'DEFAULT_FOLDER'; + } if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -842,6 +894,9 @@ abstract class ContentFolder implements ActiveRecordInterface case 'FOLDER_ID': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; + case 'DEFAULT_FOLDER': + $stmt->bindValue($identifier, (int) $this->default_folder, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -910,9 +965,12 @@ abstract class ContentFolder implements ActiveRecordInterface return $this->getFolderId(); break; case 2: - return $this->getCreatedAt(); + return $this->getDefaultFolder(); break; case 3: + return $this->getCreatedAt(); + break; + case 4: return $this->getUpdatedAt(); break; default: @@ -946,8 +1004,9 @@ abstract class ContentFolder implements ActiveRecordInterface $result = array( $keys[0] => $this->getContentId(), $keys[1] => $this->getFolderId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), + $keys[2] => $this->getDefaultFolder(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1003,9 +1062,12 @@ abstract class ContentFolder implements ActiveRecordInterface $this->setFolderId($value); break; case 2: - $this->setCreatedAt($value); + $this->setDefaultFolder($value); break; case 3: + $this->setCreatedAt($value); + break; + case 4: $this->setUpdatedAt($value); break; } // switch() @@ -1034,8 +1096,9 @@ abstract class ContentFolder implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setContentId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); + if (array_key_exists($keys[2], $arr)) $this->setDefaultFolder($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } /** @@ -1049,6 +1112,7 @@ abstract class ContentFolder implements ActiveRecordInterface if ($this->isColumnModified(ContentFolderTableMap::CONTENT_ID)) $criteria->add(ContentFolderTableMap::CONTENT_ID, $this->content_id); if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) $criteria->add(ContentFolderTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(ContentFolderTableMap::DEFAULT_FOLDER)) $criteria->add(ContentFolderTableMap::DEFAULT_FOLDER, $this->default_folder); if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) $criteria->add(ContentFolderTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) $criteria->add(ContentFolderTableMap::UPDATED_AT, $this->updated_at); @@ -1123,6 +1187,7 @@ abstract class ContentFolder implements ActiveRecordInterface { $copyObj->setContentId($this->getContentId()); $copyObj->setFolderId($this->getFolderId()); + $copyObj->setDefaultFolder($this->getDefaultFolder()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1261,6 +1326,7 @@ abstract class ContentFolder implements ActiveRecordInterface { $this->content_id = null; $this->folder_id = null; + $this->default_folder = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ContentFolderQuery.php b/core/lib/Thelia/Model/Base/ContentFolderQuery.php index 208ba80cf..72561ae77 100644 --- a/core/lib/Thelia/Model/Base/ContentFolderQuery.php +++ b/core/lib/Thelia/Model/Base/ContentFolderQuery.php @@ -23,11 +23,13 @@ use Thelia\Model\Map\ContentFolderTableMap; * * @method ChildContentFolderQuery orderByContentId($order = Criteria::ASC) Order by the content_id column * @method ChildContentFolderQuery orderByFolderId($order = Criteria::ASC) Order by the folder_id column + * @method ChildContentFolderQuery orderByDefaultFolder($order = Criteria::ASC) Order by the default_folder column * @method ChildContentFolderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildContentFolderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildContentFolderQuery groupByContentId() Group by the content_id column * @method ChildContentFolderQuery groupByFolderId() Group by the folder_id column + * @method ChildContentFolderQuery groupByDefaultFolder() Group by the default_folder column * @method ChildContentFolderQuery groupByCreatedAt() Group by the created_at column * @method ChildContentFolderQuery groupByUpdatedAt() Group by the updated_at column * @@ -48,11 +50,13 @@ use Thelia\Model\Map\ContentFolderTableMap; * * @method ChildContentFolder findOneByContentId(int $content_id) Return the first ChildContentFolder filtered by the content_id column * @method ChildContentFolder findOneByFolderId(int $folder_id) Return the first ChildContentFolder filtered by the folder_id column + * @method ChildContentFolder findOneByDefaultFolder(boolean $default_folder) Return the first ChildContentFolder filtered by the default_folder column * @method ChildContentFolder findOneByCreatedAt(string $created_at) Return the first ChildContentFolder filtered by the created_at column * @method ChildContentFolder findOneByUpdatedAt(string $updated_at) Return the first ChildContentFolder filtered by the updated_at column * * @method array findByContentId(int $content_id) Return ChildContentFolder objects filtered by the content_id column * @method array findByFolderId(int $folder_id) Return ChildContentFolder objects filtered by the folder_id column + * @method array findByDefaultFolder(boolean $default_folder) Return ChildContentFolder objects filtered by the default_folder column * @method array findByCreatedAt(string $created_at) Return ChildContentFolder objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildContentFolder objects filtered by the updated_at column * @@ -143,7 +147,7 @@ abstract class ContentFolderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT CONTENT_ID, FOLDER_ID, CREATED_AT, UPDATED_AT FROM content_folder WHERE CONTENT_ID = :p0 AND FOLDER_ID = :p1'; + $sql = 'SELECT CONTENT_ID, FOLDER_ID, DEFAULT_FOLDER, CREATED_AT, UPDATED_AT FROM content_folder WHERE CONTENT_ID = :p0 AND FOLDER_ID = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -330,6 +334,33 @@ abstract class ContentFolderQuery extends ModelCriteria return $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId, $comparison); } + /** + * Filter the query on the default_folder column + * + * Example usage: + * + * $query->filterByDefaultFolder(true); // WHERE default_folder = true + * $query->filterByDefaultFolder('yes'); // WHERE default_folder = true + * + * + * @param boolean|string $defaultFolder The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentFolderQuery The current query, for fluid interface + */ + public function filterByDefaultFolder($defaultFolder = null, $comparison = null) + { + if (is_string($defaultFolder)) { + $default_folder = in_array(strtolower($defaultFolder), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(ContentFolderTableMap::DEFAULT_FOLDER, $defaultFolder, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index 90fd48880..86cc8220b 100644 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -93,6 +93,12 @@ abstract class Country implements ActiveRecordInterface */ protected $isoalpha3; + /** + * The value for the by_default field. + * @var int + */ + protected $by_default; + /** * The value for the created_at field. * @var string @@ -477,6 +483,17 @@ abstract class Country implements ActiveRecordInterface return $this->isoalpha3; } + /** + * Get the [by_default] column value. + * + * @return int + */ + public function getByDefault() + { + + return $this->by_default; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -626,6 +643,27 @@ abstract class Country implements ActiveRecordInterface return $this; } // setIsoalpha3() + /** + * Set the value of [by_default] column. + * + * @param int $v new value + * @return \Thelia\Model\Country The current object (for fluent API support) + */ + public function setByDefault($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->by_default !== $v) { + $this->by_default = $v; + $this->modifiedColumns[] = CountryTableMap::BY_DEFAULT; + } + + + return $this; + } // setByDefault() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -720,13 +758,16 @@ abstract class Country implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryTableMap::translateFieldName('Isoalpha3', TableMap::TYPE_PHPNAME, $indexType)]; $this->isoalpha3 = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->by_default = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -739,7 +780,7 @@ abstract class Country implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = CountryTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = CountryTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e); @@ -1043,6 +1084,9 @@ abstract class Country implements ActiveRecordInterface if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) { $modifiedColumns[':p' . $index++] = 'ISOALPHA3'; } + if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; + } if ($this->isColumnModified(CountryTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1075,6 +1119,9 @@ abstract class Country implements ActiveRecordInterface case 'ISOALPHA3': $stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR); break; + case 'BY_DEFAULT': + $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1152,9 +1199,12 @@ abstract class Country implements ActiveRecordInterface return $this->getIsoalpha3(); break; case 5: - return $this->getCreatedAt(); + return $this->getByDefault(); break; case 6: + return $this->getCreatedAt(); + break; + case 7: return $this->getUpdatedAt(); break; default: @@ -1191,8 +1241,9 @@ abstract class Country implements ActiveRecordInterface $keys[2] => $this->getIsocode(), $keys[3] => $this->getIsoalpha2(), $keys[4] => $this->getIsoalpha3(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), + $keys[5] => $this->getByDefault(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1263,9 +1314,12 @@ abstract class Country implements ActiveRecordInterface $this->setIsoalpha3($value); break; case 5: - $this->setCreatedAt($value); + $this->setByDefault($value); break; case 6: + $this->setCreatedAt($value); + break; + case 7: $this->setUpdatedAt($value); break; } // switch() @@ -1297,8 +1351,9 @@ abstract class Country implements ActiveRecordInterface if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); } /** @@ -1315,6 +1370,7 @@ abstract class Country implements ActiveRecordInterface if ($this->isColumnModified(CountryTableMap::ISOCODE)) $criteria->add(CountryTableMap::ISOCODE, $this->isocode); if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2); if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3); + if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) $criteria->add(CountryTableMap::BY_DEFAULT, $this->by_default); if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::UPDATED_AT, $this->updated_at); @@ -1385,6 +1441,7 @@ abstract class Country implements ActiveRecordInterface $copyObj->setIsocode($this->getIsocode()); $copyObj->setIsoalpha2($this->getIsoalpha2()); $copyObj->setIsoalpha3($this->getIsoalpha3()); + $copyObj->setByDefault($this->getByDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2287,6 +2344,7 @@ abstract class Country implements ActiveRecordInterface $this->isocode = null; $this->isoalpha2 = null; $this->isoalpha3 = null; + $this->by_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php index 1e565e9c0..5e60f1821 100644 --- a/core/lib/Thelia/Model/Base/CountryQuery.php +++ b/core/lib/Thelia/Model/Base/CountryQuery.php @@ -27,6 +27,7 @@ use Thelia\Model\Map\CountryTableMap; * @method ChildCountryQuery orderByIsocode($order = Criteria::ASC) Order by the isocode column * @method ChildCountryQuery orderByIsoalpha2($order = Criteria::ASC) Order by the isoalpha2 column * @method ChildCountryQuery orderByIsoalpha3($order = Criteria::ASC) Order by the isoalpha3 column + * @method ChildCountryQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column * @method ChildCountryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCountryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -35,6 +36,7 @@ use Thelia\Model\Map\CountryTableMap; * @method ChildCountryQuery groupByIsocode() Group by the isocode column * @method ChildCountryQuery groupByIsoalpha2() Group by the isoalpha2 column * @method ChildCountryQuery groupByIsoalpha3() Group by the isoalpha3 column + * @method ChildCountryQuery groupByByDefault() Group by the by_default column * @method ChildCountryQuery groupByCreatedAt() Group by the created_at column * @method ChildCountryQuery groupByUpdatedAt() Group by the updated_at column * @@ -66,6 +68,7 @@ use Thelia\Model\Map\CountryTableMap; * @method ChildCountry findOneByIsocode(string $isocode) Return the first ChildCountry filtered by the isocode column * @method ChildCountry findOneByIsoalpha2(string $isoalpha2) Return the first ChildCountry filtered by the isoalpha2 column * @method ChildCountry findOneByIsoalpha3(string $isoalpha3) Return the first ChildCountry filtered by the isoalpha3 column + * @method ChildCountry findOneByByDefault(int $by_default) Return the first ChildCountry filtered by the by_default column * @method ChildCountry findOneByCreatedAt(string $created_at) Return the first ChildCountry filtered by the created_at column * @method ChildCountry findOneByUpdatedAt(string $updated_at) Return the first ChildCountry filtered by the updated_at column * @@ -74,6 +77,7 @@ use Thelia\Model\Map\CountryTableMap; * @method array findByIsocode(string $isocode) Return ChildCountry objects filtered by the isocode column * @method array findByIsoalpha2(string $isoalpha2) Return ChildCountry objects filtered by the isoalpha2 column * @method array findByIsoalpha3(string $isoalpha3) Return ChildCountry objects filtered by the isoalpha3 column + * @method array findByByDefault(int $by_default) Return ChildCountry objects filtered by the by_default column * @method array findByCreatedAt(string $created_at) Return ChildCountry objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCountry objects filtered by the updated_at column * @@ -164,7 +168,7 @@ abstract class CountryQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0'; + $sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -424,6 +428,47 @@ abstract class CountryQuery extends ModelCriteria return $this->addUsingAlias(CountryTableMap::ISOALPHA3, $isoalpha3, $comparison); } + /** + * Filter the query on the by_default column + * + * Example usage: + * + * $query->filterByByDefault(1234); // WHERE by_default = 1234 + * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 + * + * + * @param mixed $byDefault The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCountryQuery The current query, for fluid interface + */ + public function filterByByDefault($byDefault = null, $comparison = null) + { + if (is_array($byDefault)) { + $useMinMax = false; + if (isset($byDefault['min'])) { + $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($byDefault['max'])) { + $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index 26d6573a9..e46176739 100644 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -987,10 +987,9 @@ abstract class Currency implements ActiveRecordInterface if ($this->ordersScheduledForDeletion !== null) { if (!$this->ordersScheduledForDeletion->isEmpty()) { - foreach ($this->ordersScheduledForDeletion as $order) { - // need to save related object because we set the relation to null - $order->save($con); - } + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->ordersScheduledForDeletion = null; } } @@ -1758,7 +1757,7 @@ abstract class Currency implements ActiveRecordInterface $this->ordersScheduledForDeletion = clone $this->collOrders; $this->ordersScheduledForDeletion->clear(); } - $this->ordersScheduledForDeletion[]= $order; + $this->ordersScheduledForDeletion[]= clone $order; $order->setCurrency(null); } @@ -1807,10 +1806,10 @@ abstract class Currency implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -1832,10 +1831,10 @@ abstract class Currency implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -1865,6 +1864,81 @@ abstract class Currency implements ActiveRecordInterface return $this->getOrders($query, $con); } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Currency is new, it will return + * an empty collection; or if this Currency has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Currency. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Currency is new, it will return + * an empty collection; or if this Currency has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Currency. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Currency is new, it will return + * an empty collection; or if this Currency has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Currency. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrders($query, $con); + } + /** * Clears out the collCarts collection * diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php index eb4b1b2f7..4276000a1 100644 --- a/core/lib/Thelia/Model/Base/CurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -596,7 +596,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyQuery The current query, for fluid interface */ - public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Order'); @@ -631,7 +631,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinOrder($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index 3d87f3e28..e7bd688af 100644 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -135,6 +135,18 @@ abstract class Customer implements ActiveRecordInterface */ protected $discount; + /** + * The value for the remember_me_token field. + * @var string + */ + protected $remember_me_token; + + /** + * The value for the remember_me_serial field. + * @var string + */ + protected $remember_me_serial; + /** * The value for the created_at field. * @var string @@ -582,6 +594,28 @@ abstract class Customer implements ActiveRecordInterface return $this->discount; } + /** + * Get the [remember_me_token] column value. + * + * @return string + */ + public function getRememberMeToken() + { + + return $this->remember_me_token; + } + + /** + * Get the [remember_me_serial] column value. + * + * @return string + */ + public function getRememberMeSerial() + { + + return $this->remember_me_serial; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -878,6 +912,48 @@ abstract class Customer implements ActiveRecordInterface return $this; } // setDiscount() + /** + * Set the value of [remember_me_token] column. + * + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) + */ + public function setRememberMeToken($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->remember_me_token !== $v) { + $this->remember_me_token = $v; + $this->modifiedColumns[] = CustomerTableMap::REMEMBER_ME_TOKEN; + } + + + return $this; + } // setRememberMeToken() + + /** + * Set the value of [remember_me_serial] column. + * + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) + */ + public function setRememberMeSerial($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->remember_me_serial !== $v) { + $this->remember_me_serial = $v; + $this->modifiedColumns[] = CustomerTableMap::REMEMBER_ME_SERIAL; + } + + + return $this; + } // setRememberMeSerial() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -993,13 +1069,19 @@ abstract class Customer implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; $this->discount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('RememberMeToken', TableMap::TYPE_PHPNAME, $indexType)]; + $this->remember_me_token = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('RememberMeSerial', TableMap::TYPE_PHPNAME, $indexType)]; + $this->remember_me_serial = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1012,7 +1094,7 @@ abstract class Customer implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 14; // 14 = CustomerTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 16; // 16 = CustomerTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e); @@ -1342,6 +1424,12 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) { $modifiedColumns[':p' . $index++] = 'DISCOUNT'; } + if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_TOKEN)) { + $modifiedColumns[':p' . $index++] = 'REMEMBER_ME_TOKEN'; + } + if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_SERIAL)) { + $modifiedColumns[':p' . $index++] = 'REMEMBER_ME_SERIAL'; + } if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1395,6 +1483,12 @@ abstract class Customer implements ActiveRecordInterface case 'DISCOUNT': $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); break; + case 'REMEMBER_ME_TOKEN': + $stmt->bindValue($identifier, $this->remember_me_token, PDO::PARAM_STR); + break; + case 'REMEMBER_ME_SERIAL': + $stmt->bindValue($identifier, $this->remember_me_serial, PDO::PARAM_STR); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1500,9 +1594,15 @@ abstract class Customer implements ActiveRecordInterface return $this->getDiscount(); break; case 12: - return $this->getCreatedAt(); + return $this->getRememberMeToken(); break; case 13: + return $this->getRememberMeSerial(); + break; + case 14: + return $this->getCreatedAt(); + break; + case 15: return $this->getUpdatedAt(); break; default: @@ -1546,8 +1646,10 @@ abstract class Customer implements ActiveRecordInterface $keys[9] => $this->getLang(), $keys[10] => $this->getSponsor(), $keys[11] => $this->getDiscount(), - $keys[12] => $this->getCreatedAt(), - $keys[13] => $this->getUpdatedAt(), + $keys[12] => $this->getRememberMeToken(), + $keys[13] => $this->getRememberMeSerial(), + $keys[14] => $this->getCreatedAt(), + $keys[15] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1639,9 +1741,15 @@ abstract class Customer implements ActiveRecordInterface $this->setDiscount($value); break; case 12: - $this->setCreatedAt($value); + $this->setRememberMeToken($value); break; case 13: + $this->setRememberMeSerial($value); + break; + case 14: + $this->setCreatedAt($value); + break; + case 15: $this->setUpdatedAt($value); break; } // switch() @@ -1680,8 +1788,10 @@ abstract class Customer implements ActiveRecordInterface if (array_key_exists($keys[9], $arr)) $this->setLang($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setSponsor($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setDiscount($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); + if (array_key_exists($keys[12], $arr)) $this->setRememberMeToken($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setRememberMeSerial($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); } /** @@ -1705,6 +1815,8 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::LANG)) $criteria->add(CustomerTableMap::LANG, $this->lang); if ($this->isColumnModified(CustomerTableMap::SPONSOR)) $criteria->add(CustomerTableMap::SPONSOR, $this->sponsor); if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) $criteria->add(CustomerTableMap::DISCOUNT, $this->discount); + if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_TOKEN)) $criteria->add(CustomerTableMap::REMEMBER_ME_TOKEN, $this->remember_me_token); + if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_SERIAL)) $criteria->add(CustomerTableMap::REMEMBER_ME_SERIAL, $this->remember_me_serial); if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) $criteria->add(CustomerTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CustomerTableMap::UPDATED_AT)) $criteria->add(CustomerTableMap::UPDATED_AT, $this->updated_at); @@ -1781,6 +1893,8 @@ abstract class Customer implements ActiveRecordInterface $copyObj->setLang($this->getLang()); $copyObj->setSponsor($this->getSponsor()); $copyObj->setDiscount($this->getDiscount()); + $copyObj->setRememberMeToken($this->getRememberMeToken()); + $copyObj->setRememberMeSerial($this->getRememberMeSerial()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2438,10 +2552,10 @@ abstract class Customer implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -2463,10 +2577,10 @@ abstract class Customer implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -2496,6 +2610,81 @@ abstract class Customer implements ActiveRecordInterface return $this->getOrders($query, $con); } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrders($query, $con); + } + /** * Clears out the collCarts collection * @@ -2806,6 +2995,8 @@ abstract class Customer implements ActiveRecordInterface $this->lang = null; $this->sponsor = null; $this->discount = null; + $this->remember_me_token = null; + $this->remember_me_serial = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php index f02e76c24..897bb5ee9 100644 --- a/core/lib/Thelia/Model/Base/CustomerQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerQuery.php @@ -33,6 +33,8 @@ use Thelia\Model\Map\CustomerTableMap; * @method ChildCustomerQuery orderByLang($order = Criteria::ASC) Order by the lang column * @method ChildCustomerQuery orderBySponsor($order = Criteria::ASC) Order by the sponsor column * @method ChildCustomerQuery orderByDiscount($order = Criteria::ASC) Order by the discount column + * @method ChildCustomerQuery orderByRememberMeToken($order = Criteria::ASC) Order by the remember_me_token column + * @method ChildCustomerQuery orderByRememberMeSerial($order = Criteria::ASC) Order by the remember_me_serial column * @method ChildCustomerQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCustomerQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -48,6 +50,8 @@ use Thelia\Model\Map\CustomerTableMap; * @method ChildCustomerQuery groupByLang() Group by the lang column * @method ChildCustomerQuery groupBySponsor() Group by the sponsor column * @method ChildCustomerQuery groupByDiscount() Group by the discount column + * @method ChildCustomerQuery groupByRememberMeToken() Group by the remember_me_token column + * @method ChildCustomerQuery groupByRememberMeSerial() Group by the remember_me_serial column * @method ChildCustomerQuery groupByCreatedAt() Group by the created_at column * @method ChildCustomerQuery groupByUpdatedAt() Group by the updated_at column * @@ -86,6 +90,8 @@ use Thelia\Model\Map\CustomerTableMap; * @method ChildCustomer findOneByLang(string $lang) Return the first ChildCustomer filtered by the lang column * @method ChildCustomer findOneBySponsor(string $sponsor) Return the first ChildCustomer filtered by the sponsor column * @method ChildCustomer findOneByDiscount(double $discount) Return the first ChildCustomer filtered by the discount column + * @method ChildCustomer findOneByRememberMeToken(string $remember_me_token) Return the first ChildCustomer filtered by the remember_me_token column + * @method ChildCustomer findOneByRememberMeSerial(string $remember_me_serial) Return the first ChildCustomer filtered by the remember_me_serial column * @method ChildCustomer findOneByCreatedAt(string $created_at) Return the first ChildCustomer filtered by the created_at column * @method ChildCustomer findOneByUpdatedAt(string $updated_at) Return the first ChildCustomer filtered by the updated_at column * @@ -101,6 +107,8 @@ use Thelia\Model\Map\CustomerTableMap; * @method array findByLang(string $lang) Return ChildCustomer objects filtered by the lang column * @method array findBySponsor(string $sponsor) Return ChildCustomer objects filtered by the sponsor column * @method array findByDiscount(double $discount) Return ChildCustomer objects filtered by the discount column + * @method array findByRememberMeToken(string $remember_me_token) Return ChildCustomer objects filtered by the remember_me_token column + * @method array findByRememberMeSerial(string $remember_me_serial) Return ChildCustomer objects filtered by the remember_me_serial column * @method array findByCreatedAt(string $created_at) Return ChildCustomer objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCustomer objects filtered by the updated_at column * @@ -191,7 +199,7 @@ abstract class CustomerQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, TITLE_ID, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; + $sql = 'SELECT ID, REF, TITLE_ID, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, REMEMBER_ME_TOKEN, REMEMBER_ME_SERIAL, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -678,6 +686,64 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount, $comparison); } + /** + * Filter the query on the remember_me_token column + * + * Example usage: + * + * $query->filterByRememberMeToken('fooValue'); // WHERE remember_me_token = 'fooValue' + * $query->filterByRememberMeToken('%fooValue%'); // WHERE remember_me_token LIKE '%fooValue%' + * + * + * @param string $rememberMeToken The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerQuery The current query, for fluid interface + */ + public function filterByRememberMeToken($rememberMeToken = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($rememberMeToken)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $rememberMeToken)) { + $rememberMeToken = str_replace('*', '%', $rememberMeToken); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CustomerTableMap::REMEMBER_ME_TOKEN, $rememberMeToken, $comparison); + } + + /** + * Filter the query on the remember_me_serial column + * + * Example usage: + * + * $query->filterByRememberMeSerial('fooValue'); // WHERE remember_me_serial = 'fooValue' + * $query->filterByRememberMeSerial('%fooValue%'); // WHERE remember_me_serial LIKE '%fooValue%' + * + * + * @param string $rememberMeSerial The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerQuery The current query, for fluid interface + */ + public function filterByRememberMeSerial($rememberMeSerial = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($rememberMeSerial)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $rememberMeSerial)) { + $rememberMeSerial = str_replace('*', '%', $rememberMeSerial); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CustomerTableMap::REMEMBER_ME_SERIAL, $rememberMeSerial, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index 2860a4155..c9b6c5ed4 100644 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -17,18 +17,18 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Category as ChildCategory; -use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\Feature as ChildFeature; use Thelia\Model\FeatureAv as ChildFeatureAv; use Thelia\Model\FeatureAvQuery as ChildFeatureAvQuery; -use Thelia\Model\FeatureCategory as ChildFeatureCategory; -use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; use Thelia\Model\FeatureI18n as ChildFeatureI18n; use Thelia\Model\FeatureI18nQuery as ChildFeatureI18nQuery; use Thelia\Model\FeatureProduct as ChildFeatureProduct; use Thelia\Model\FeatureProductQuery as ChildFeatureProductQuery; use Thelia\Model\FeatureQuery as ChildFeatureQuery; +use Thelia\Model\FeatureTemplate as ChildFeatureTemplate; +use Thelia\Model\FeatureTemplateQuery as ChildFeatureTemplateQuery; +use Thelia\Model\Template as ChildTemplate; +use Thelia\Model\TemplateQuery as ChildTemplateQuery; use Thelia\Model\Map\FeatureTableMap; abstract class Feature implements ActiveRecordInterface @@ -109,10 +109,10 @@ abstract class Feature implements ActiveRecordInterface protected $collFeatureProductsPartial; /** - * @var ObjectCollection|ChildFeatureCategory[] Collection to store aggregation of ChildFeatureCategory objects. + * @var ObjectCollection|ChildFeatureTemplate[] Collection to store aggregation of ChildFeatureTemplate objects. */ - protected $collFeatureCategories; - protected $collFeatureCategoriesPartial; + protected $collFeatureTemplates; + protected $collFeatureTemplatesPartial; /** * @var ObjectCollection|ChildFeatureI18n[] Collection to store aggregation of ChildFeatureI18n objects. @@ -121,9 +121,9 @@ abstract class Feature implements ActiveRecordInterface protected $collFeatureI18nsPartial; /** - * @var ChildCategory[] Collection to store aggregation of ChildCategory objects. + * @var ChildTemplate[] Collection to store aggregation of ChildTemplate objects. */ - protected $collCategories; + protected $collTemplates; /** * Flag to prevent endless save loop, if this object is referenced @@ -151,7 +151,7 @@ abstract class Feature implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $categoriesScheduledForDeletion = null; + protected $templatesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -169,7 +169,7 @@ abstract class Feature implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $featureCategoriesScheduledForDeletion = null; + protected $featureTemplatesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -756,11 +756,11 @@ abstract class Feature implements ActiveRecordInterface $this->collFeatureProducts = null; - $this->collFeatureCategories = null; + $this->collFeatureTemplates = null; $this->collFeatureI18ns = null; - $this->collCategories = null; + $this->collTemplates = null; } // if (deep) } @@ -894,29 +894,29 @@ abstract class Feature implements ActiveRecordInterface $this->resetModified(); } - if ($this->categoriesScheduledForDeletion !== null) { - if (!$this->categoriesScheduledForDeletion->isEmpty()) { + if ($this->templatesScheduledForDeletion !== null) { + if (!$this->templatesScheduledForDeletion->isEmpty()) { $pks = array(); $pk = $this->getPrimaryKey(); - foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); + foreach ($this->templatesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pks[] = array($pk, $remotePk); } - FeatureCategoryQuery::create() + FeatureTemplateQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->categoriesScheduledForDeletion = null; + $this->templatesScheduledForDeletion = null; } - foreach ($this->getCategories() as $category) { - if ($category->isModified()) { - $category->save($con); + foreach ($this->getTemplates() as $template) { + if ($template->isModified()) { + $template->save($con); } } - } elseif ($this->collCategories) { - foreach ($this->collCategories as $category) { - if ($category->isModified()) { - $category->save($con); + } elseif ($this->collTemplates) { + foreach ($this->collTemplates as $template) { + if ($template->isModified()) { + $template->save($con); } } } @@ -955,17 +955,17 @@ abstract class Feature implements ActiveRecordInterface } } - if ($this->featureCategoriesScheduledForDeletion !== null) { - if (!$this->featureCategoriesScheduledForDeletion->isEmpty()) { - \Thelia\Model\FeatureCategoryQuery::create() - ->filterByPrimaryKeys($this->featureCategoriesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->featureTemplatesScheduledForDeletion !== null) { + if (!$this->featureTemplatesScheduledForDeletion->isEmpty()) { + \Thelia\Model\FeatureTemplateQuery::create() + ->filterByPrimaryKeys($this->featureTemplatesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->featureCategoriesScheduledForDeletion = null; + $this->featureTemplatesScheduledForDeletion = null; } } - if ($this->collFeatureCategories !== null) { - foreach ($this->collFeatureCategories as $referrerFK) { + if ($this->collFeatureTemplates !== null) { + foreach ($this->collFeatureTemplates as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1181,8 +1181,8 @@ abstract class Feature implements ActiveRecordInterface if (null !== $this->collFeatureProducts) { $result['FeatureProducts'] = $this->collFeatureProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collFeatureCategories) { - $result['FeatureCategories'] = $this->collFeatureCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collFeatureTemplates) { + $result['FeatureTemplates'] = $this->collFeatureTemplates->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collFeatureI18ns) { $result['FeatureI18ns'] = $this->collFeatureI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1366,9 +1366,9 @@ abstract class Feature implements ActiveRecordInterface } } - foreach ($this->getFeatureCategories() as $relObj) { + foreach ($this->getFeatureTemplates() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureCategory($relObj->copy($deepCopy)); + $copyObj->addFeatureTemplate($relObj->copy($deepCopy)); } } @@ -1425,8 +1425,8 @@ abstract class Feature implements ActiveRecordInterface if ('FeatureProduct' == $relationName) { return $this->initFeatureProducts(); } - if ('FeatureCategory' == $relationName) { - return $this->initFeatureCategories(); + if ('FeatureTemplate' == $relationName) { + return $this->initFeatureTemplates(); } if ('FeatureI18n' == $relationName) { return $this->initFeatureI18ns(); @@ -1920,31 +1920,31 @@ abstract class Feature implements ActiveRecordInterface } /** - * Clears out the collFeatureCategories collection + * Clears out the collFeatureTemplates collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addFeatureCategories() + * @see addFeatureTemplates() */ - public function clearFeatureCategories() + public function clearFeatureTemplates() { - $this->collFeatureCategories = null; // important to set this to NULL since that means it is uninitialized + $this->collFeatureTemplates = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collFeatureCategories collection loaded partially. + * Reset is the collFeatureTemplates collection loaded partially. */ - public function resetPartialFeatureCategories($v = true) + public function resetPartialFeatureTemplates($v = true) { - $this->collFeatureCategoriesPartial = $v; + $this->collFeatureTemplatesPartial = $v; } /** - * Initializes the collFeatureCategories collection. + * Initializes the collFeatureTemplates collection. * - * By default this just sets the collFeatureCategories collection to an empty array (like clearcollFeatureCategories()); + * By default this just sets the collFeatureTemplates collection to an empty array (like clearcollFeatureTemplates()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1953,17 +1953,17 @@ abstract class Feature implements ActiveRecordInterface * * @return void */ - public function initFeatureCategories($overrideExisting = true) + public function initFeatureTemplates($overrideExisting = true) { - if (null !== $this->collFeatureCategories && !$overrideExisting) { + if (null !== $this->collFeatureTemplates && !$overrideExisting) { return; } - $this->collFeatureCategories = new ObjectCollection(); - $this->collFeatureCategories->setModel('\Thelia\Model\FeatureCategory'); + $this->collFeatureTemplates = new ObjectCollection(); + $this->collFeatureTemplates->setModel('\Thelia\Model\FeatureTemplate'); } /** - * Gets an array of ChildFeatureCategory objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureTemplate objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1973,109 +1973,109 @@ abstract class Feature implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects + * @return Collection|ChildFeatureTemplate[] List of ChildFeatureTemplate objects * @throws PropelException */ - public function getFeatureCategories($criteria = null, ConnectionInterface $con = null) + public function getFeatureTemplates($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); - if (null === $this->collFeatureCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategories) { + $partial = $this->collFeatureTemplatesPartial && !$this->isNew(); + if (null === $this->collFeatureTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureTemplates) { // return empty collection - $this->initFeatureCategories(); + $this->initFeatureTemplates(); } else { - $collFeatureCategories = ChildFeatureCategoryQuery::create(null, $criteria) + $collFeatureTemplates = ChildFeatureTemplateQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collFeatureCategoriesPartial && count($collFeatureCategories)) { - $this->initFeatureCategories(false); + if (false !== $this->collFeatureTemplatesPartial && count($collFeatureTemplates)) { + $this->initFeatureTemplates(false); - foreach ($collFeatureCategories as $obj) { - if (false == $this->collFeatureCategories->contains($obj)) { - $this->collFeatureCategories->append($obj); + foreach ($collFeatureTemplates as $obj) { + if (false == $this->collFeatureTemplates->contains($obj)) { + $this->collFeatureTemplates->append($obj); } } - $this->collFeatureCategoriesPartial = true; + $this->collFeatureTemplatesPartial = true; } - $collFeatureCategories->getInternalIterator()->rewind(); + $collFeatureTemplates->getInternalIterator()->rewind(); - return $collFeatureCategories; + return $collFeatureTemplates; } - if ($partial && $this->collFeatureCategories) { - foreach ($this->collFeatureCategories as $obj) { + if ($partial && $this->collFeatureTemplates) { + foreach ($this->collFeatureTemplates as $obj) { if ($obj->isNew()) { - $collFeatureCategories[] = $obj; + $collFeatureTemplates[] = $obj; } } } - $this->collFeatureCategories = $collFeatureCategories; - $this->collFeatureCategoriesPartial = false; + $this->collFeatureTemplates = $collFeatureTemplates; + $this->collFeatureTemplatesPartial = false; } } - return $this->collFeatureCategories; + return $this->collFeatureTemplates; } /** - * Sets a collection of FeatureCategory objects related by a one-to-many relationship + * Sets a collection of FeatureTemplate objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $featureCategories A Propel collection. + * @param Collection $featureTemplates A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildFeature The current object (for fluent API support) */ - public function setFeatureCategories(Collection $featureCategories, ConnectionInterface $con = null) + public function setFeatureTemplates(Collection $featureTemplates, ConnectionInterface $con = null) { - $featureCategoriesToDelete = $this->getFeatureCategories(new Criteria(), $con)->diff($featureCategories); + $featureTemplatesToDelete = $this->getFeatureTemplates(new Criteria(), $con)->diff($featureTemplates); - $this->featureCategoriesScheduledForDeletion = $featureCategoriesToDelete; + $this->featureTemplatesScheduledForDeletion = $featureTemplatesToDelete; - foreach ($featureCategoriesToDelete as $featureCategoryRemoved) { - $featureCategoryRemoved->setFeature(null); + foreach ($featureTemplatesToDelete as $featureTemplateRemoved) { + $featureTemplateRemoved->setFeature(null); } - $this->collFeatureCategories = null; - foreach ($featureCategories as $featureCategory) { - $this->addFeatureCategory($featureCategory); + $this->collFeatureTemplates = null; + foreach ($featureTemplates as $featureTemplate) { + $this->addFeatureTemplate($featureTemplate); } - $this->collFeatureCategories = $featureCategories; - $this->collFeatureCategoriesPartial = false; + $this->collFeatureTemplates = $featureTemplates; + $this->collFeatureTemplatesPartial = false; return $this; } /** - * Returns the number of related FeatureCategory objects. + * Returns the number of related FeatureTemplate objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related FeatureCategory objects. + * @return int Count of related FeatureTemplate objects. * @throws PropelException */ - public function countFeatureCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countFeatureTemplates(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); - if (null === $this->collFeatureCategories || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategories) { + $partial = $this->collFeatureTemplatesPartial && !$this->isNew(); + if (null === $this->collFeatureTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureTemplates) { return 0; } if ($partial && !$criteria) { - return count($this->getFeatureCategories()); + return count($this->getFeatureTemplates()); } - $query = ChildFeatureCategoryQuery::create(null, $criteria); + $query = ChildFeatureTemplateQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2085,53 +2085,53 @@ abstract class Feature implements ActiveRecordInterface ->count($con); } - return count($this->collFeatureCategories); + return count($this->collFeatureTemplates); } /** - * Method called to associate a ChildFeatureCategory object to this object - * through the ChildFeatureCategory foreign key attribute. + * Method called to associate a ChildFeatureTemplate object to this object + * through the ChildFeatureTemplate foreign key attribute. * - * @param ChildFeatureCategory $l ChildFeatureCategory + * @param ChildFeatureTemplate $l ChildFeatureTemplate * @return \Thelia\Model\Feature The current object (for fluent API support) */ - public function addFeatureCategory(ChildFeatureCategory $l) + public function addFeatureTemplate(ChildFeatureTemplate $l) { - if ($this->collFeatureCategories === null) { - $this->initFeatureCategories(); - $this->collFeatureCategoriesPartial = true; + if ($this->collFeatureTemplates === null) { + $this->initFeatureTemplates(); + $this->collFeatureTemplatesPartial = true; } - if (!in_array($l, $this->collFeatureCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureCategory($l); + if (!in_array($l, $this->collFeatureTemplates->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddFeatureTemplate($l); } return $this; } /** - * @param FeatureCategory $featureCategory The featureCategory object to add. + * @param FeatureTemplate $featureTemplate The featureTemplate object to add. */ - protected function doAddFeatureCategory($featureCategory) + protected function doAddFeatureTemplate($featureTemplate) { - $this->collFeatureCategories[]= $featureCategory; - $featureCategory->setFeature($this); + $this->collFeatureTemplates[]= $featureTemplate; + $featureTemplate->setFeature($this); } /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. + * @param FeatureTemplate $featureTemplate The featureTemplate object to remove. * @return ChildFeature The current object (for fluent API support) */ - public function removeFeatureCategory($featureCategory) + public function removeFeatureTemplate($featureTemplate) { - if ($this->getFeatureCategories()->contains($featureCategory)) { - $this->collFeatureCategories->remove($this->collFeatureCategories->search($featureCategory)); - if (null === $this->featureCategoriesScheduledForDeletion) { - $this->featureCategoriesScheduledForDeletion = clone $this->collFeatureCategories; - $this->featureCategoriesScheduledForDeletion->clear(); + if ($this->getFeatureTemplates()->contains($featureTemplate)) { + $this->collFeatureTemplates->remove($this->collFeatureTemplates->search($featureTemplate)); + if (null === $this->featureTemplatesScheduledForDeletion) { + $this->featureTemplatesScheduledForDeletion = clone $this->collFeatureTemplates; + $this->featureTemplatesScheduledForDeletion->clear(); } - $this->featureCategoriesScheduledForDeletion[]= clone $featureCategory; - $featureCategory->setFeature(null); + $this->featureTemplatesScheduledForDeletion[]= clone $featureTemplate; + $featureTemplate->setFeature(null); } return $this; @@ -2143,7 +2143,7 @@ abstract class Feature implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this Feature is new, it will return * an empty collection; or if this Feature has previously - * been saved, it will retrieve related FeatureCategories from storage. + * been saved, it will retrieve related FeatureTemplates from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2152,14 +2152,14 @@ abstract class Feature implements ActiveRecordInterface * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects + * @return Collection|ChildFeatureTemplate[] List of ChildFeatureTemplate objects */ - public function getFeatureCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getFeatureTemplatesJoinTemplate($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ChildFeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); + $query = ChildFeatureTemplateQuery::create(null, $criteria); + $query->joinWith('Template', $joinBehavior); - return $this->getFeatureCategories($query, $con); + return $this->getFeatureTemplates($query, $con); } /** @@ -2388,38 +2388,38 @@ abstract class Feature implements ActiveRecordInterface } /** - * Clears out the collCategories collection + * Clears out the collTemplates collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addCategories() + * @see addTemplates() */ - public function clearCategories() + public function clearTemplates() { - $this->collCategories = null; // important to set this to NULL since that means it is uninitialized - $this->collCategoriesPartial = null; + $this->collTemplates = null; // important to set this to NULL since that means it is uninitialized + $this->collTemplatesPartial = null; } /** - * Initializes the collCategories collection. + * Initializes the collTemplates collection. * - * By default this just sets the collCategories collection to an empty collection (like clearCategories()); + * By default this just sets the collTemplates collection to an empty collection (like clearTemplates()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * * @return void */ - public function initCategories() + public function initTemplates() { - $this->collCategories = new ObjectCollection(); - $this->collCategories->setModel('\Thelia\Model\Category'); + $this->collTemplates = new ObjectCollection(); + $this->collTemplates->setModel('\Thelia\Model\Template'); } /** - * Gets a collection of ChildCategory objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. + * Gets a collection of ChildTemplate objects related by a many-to-many relationship + * to the current object by way of the feature_template cross-reference table. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -2430,73 +2430,73 @@ abstract class Feature implements ActiveRecordInterface * @param Criteria $criteria Optional query object to filter the query * @param ConnectionInterface $con Optional connection object * - * @return ObjectCollection|ChildCategory[] List of ChildCategory objects + * @return ObjectCollection|ChildTemplate[] List of ChildTemplate objects */ - public function getCategories($criteria = null, ConnectionInterface $con = null) + public function getTemplates($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collCategories || null !== $criteria) { - if ($this->isNew() && null === $this->collCategories) { + if (null === $this->collTemplates || null !== $criteria) { + if ($this->isNew() && null === $this->collTemplates) { // return empty collection - $this->initCategories(); + $this->initTemplates(); } else { - $collCategories = ChildCategoryQuery::create(null, $criteria) + $collTemplates = ChildTemplateQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); if (null !== $criteria) { - return $collCategories; + return $collTemplates; } - $this->collCategories = $collCategories; + $this->collTemplates = $collTemplates; } } - return $this->collCategories; + return $this->collTemplates; } /** - * Sets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. + * Sets a collection of Template objects related by a many-to-many relationship + * to the current object by way of the feature_template cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $categories A Propel collection. + * @param Collection $templates A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildFeature The current object (for fluent API support) */ - public function setCategories(Collection $categories, ConnectionInterface $con = null) + public function setTemplates(Collection $templates, ConnectionInterface $con = null) { - $this->clearCategories(); - $currentCategories = $this->getCategories(); + $this->clearTemplates(); + $currentTemplates = $this->getTemplates(); - $this->categoriesScheduledForDeletion = $currentCategories->diff($categories); + $this->templatesScheduledForDeletion = $currentTemplates->diff($templates); - foreach ($categories as $category) { - if (!$currentCategories->contains($category)) { - $this->doAddCategory($category); + foreach ($templates as $template) { + if (!$currentTemplates->contains($template)) { + $this->doAddTemplate($template); } } - $this->collCategories = $categories; + $this->collTemplates = $templates; return $this; } /** - * Gets the number of ChildCategory objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. + * Gets the number of ChildTemplate objects related by a many-to-many relationship + * to the current object by way of the feature_template cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param ConnectionInterface $con Optional connection object * - * @return int the number of related ChildCategory objects + * @return int the number of related ChildTemplate objects */ - public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countTemplates($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collCategories || null !== $criteria) { - if ($this->isNew() && null === $this->collCategories) { + if (null === $this->collTemplates || null !== $criteria) { + if ($this->isNew() && null === $this->collTemplates) { return 0; } else { - $query = ChildCategoryQuery::create(null, $criteria); + $query = ChildTemplateQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2506,65 +2506,65 @@ abstract class Feature implements ActiveRecordInterface ->count($con); } } else { - return count($this->collCategories); + return count($this->collTemplates); } } /** - * Associate a ChildCategory object to this object - * through the feature_category cross reference table. + * Associate a ChildTemplate object to this object + * through the feature_template cross reference table. * - * @param ChildCategory $category The ChildFeatureCategory object to relate + * @param ChildTemplate $template The ChildFeatureTemplate object to relate * @return ChildFeature The current object (for fluent API support) */ - public function addCategory(ChildCategory $category) + public function addTemplate(ChildTemplate $template) { - if ($this->collCategories === null) { - $this->initCategories(); + if ($this->collTemplates === null) { + $this->initTemplates(); } - if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - $this->collCategories[] = $category; + if (!$this->collTemplates->contains($template)) { // only add it if the **same** object is not already associated + $this->doAddTemplate($template); + $this->collTemplates[] = $template; } return $this; } /** - * @param Category $category The category object to add. + * @param Template $template The template object to add. */ - protected function doAddCategory($category) + protected function doAddTemplate($template) { - $featureCategory = new ChildFeatureCategory(); - $featureCategory->setCategory($category); - $this->addFeatureCategory($featureCategory); + $featureTemplate = new ChildFeatureTemplate(); + $featureTemplate->setTemplate($template); + $this->addFeatureTemplate($featureTemplate); // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations - if (!$category->getFeatures()->contains($this)) { - $foreignCollection = $category->getFeatures(); + if (!$template->getFeatures()->contains($this)) { + $foreignCollection = $template->getFeatures(); $foreignCollection[] = $this; } } /** - * Remove a ChildCategory object to this object - * through the feature_category cross reference table. + * Remove a ChildTemplate object to this object + * through the feature_template cross reference table. * - * @param ChildCategory $category The ChildFeatureCategory object to relate + * @param ChildTemplate $template The ChildFeatureTemplate object to relate * @return ChildFeature The current object (for fluent API support) */ - public function removeCategory(ChildCategory $category) + public function removeTemplate(ChildTemplate $template) { - if ($this->getCategories()->contains($category)) { - $this->collCategories->remove($this->collCategories->search($category)); + if ($this->getTemplates()->contains($template)) { + $this->collTemplates->remove($this->collTemplates->search($template)); - if (null === $this->categoriesScheduledForDeletion) { - $this->categoriesScheduledForDeletion = clone $this->collCategories; - $this->categoriesScheduledForDeletion->clear(); + if (null === $this->templatesScheduledForDeletion) { + $this->templatesScheduledForDeletion = clone $this->collTemplates; + $this->templatesScheduledForDeletion->clear(); } - $this->categoriesScheduledForDeletion[] = $category; + $this->templatesScheduledForDeletion[] = $template; } return $this; @@ -2610,8 +2610,8 @@ abstract class Feature implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collFeatureCategories) { - foreach ($this->collFeatureCategories as $o) { + if ($this->collFeatureTemplates) { + foreach ($this->collFeatureTemplates as $o) { $o->clearAllReferences($deep); } } @@ -2620,8 +2620,8 @@ abstract class Feature implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collCategories) { - foreach ($this->collCategories as $o) { + if ($this->collTemplates) { + foreach ($this->collTemplates as $o) { $o->clearAllReferences($deep); } } @@ -2639,18 +2639,18 @@ abstract class Feature implements ActiveRecordInterface $this->collFeatureProducts->clearIterator(); } $this->collFeatureProducts = null; - if ($this->collFeatureCategories instanceof Collection) { - $this->collFeatureCategories->clearIterator(); + if ($this->collFeatureTemplates instanceof Collection) { + $this->collFeatureTemplates->clearIterator(); } - $this->collFeatureCategories = null; + $this->collFeatureTemplates = null; if ($this->collFeatureI18ns instanceof Collection) { $this->collFeatureI18ns->clearIterator(); } $this->collFeatureI18ns = null; - if ($this->collCategories instanceof Collection) { - $this->collCategories->clearIterator(); + if ($this->collTemplates instanceof Collection) { + $this->collTemplates->clearIterator(); } - $this->collCategories = null; + $this->collTemplates = null; } /** diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php index 9b00e812e..097646c87 100644 --- a/core/lib/Thelia/Model/Base/FeatureQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureQuery.php @@ -46,9 +46,9 @@ use Thelia\Model\Map\FeatureTableMap; * @method ChildFeatureQuery rightJoinFeatureProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProduct relation * @method ChildFeatureQuery innerJoinFeatureProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProduct relation * - * @method ChildFeatureQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation - * @method ChildFeatureQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation - * @method ChildFeatureQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation + * @method ChildFeatureQuery leftJoinFeatureTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureTemplate relation + * @method ChildFeatureQuery rightJoinFeatureTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureTemplate relation + * @method ChildFeatureQuery innerJoinFeatureTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureTemplate relation * * @method ChildFeatureQuery leftJoinFeatureI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureI18n relation * @method ChildFeatureQuery rightJoinFeatureI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureI18n relation @@ -601,40 +601,40 @@ abstract class FeatureQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\FeatureCategory object + * Filter the query by a related \Thelia\Model\FeatureTemplate object * - * @param \Thelia\Model\FeatureCategory|ObjectCollection $featureCategory the related object to use as filter + * @param \Thelia\Model\FeatureTemplate|ObjectCollection $featureTemplate the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildFeatureQuery The current query, for fluid interface */ - public function filterByFeatureCategory($featureCategory, $comparison = null) + public function filterByFeatureTemplate($featureTemplate, $comparison = null) { - if ($featureCategory instanceof \Thelia\Model\FeatureCategory) { + if ($featureTemplate instanceof \Thelia\Model\FeatureTemplate) { return $this - ->addUsingAlias(FeatureTableMap::ID, $featureCategory->getFeatureId(), $comparison); - } elseif ($featureCategory instanceof ObjectCollection) { + ->addUsingAlias(FeatureTableMap::ID, $featureTemplate->getFeatureId(), $comparison); + } elseif ($featureTemplate instanceof ObjectCollection) { return $this - ->useFeatureCategoryQuery() - ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) + ->useFeatureTemplateQuery() + ->filterByPrimaryKeys($featureTemplate->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection'); + throw new PropelException('filterByFeatureTemplate() only accepts arguments of type \Thelia\Model\FeatureTemplate or Collection'); } } /** - * Adds a JOIN clause to the query using the FeatureCategory relation + * Adds a JOIN clause to the query using the FeatureTemplate relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinFeatureTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureCategory'); + $relationMap = $tableMap->getRelation('FeatureTemplate'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -649,14 +649,14 @@ abstract class FeatureQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'FeatureCategory'); + $this->addJoinObject($join, 'FeatureTemplate'); } return $this; } /** - * Use the FeatureCategory relation FeatureCategory object + * Use the FeatureTemplate relation FeatureTemplate object * * @see useQuery() * @@ -664,13 +664,13 @@ abstract class FeatureQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\FeatureTemplateQuery A secondary query class using the current class as primary query */ - public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useFeatureTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinFeatureCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); + ->joinFeatureTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FeatureTemplate', '\Thelia\Model\FeatureTemplateQuery'); } /** @@ -747,19 +747,19 @@ abstract class FeatureQuery extends ModelCriteria } /** - * Filter the query by a related Category object - * using the feature_category table as cross reference + * Filter the query by a related Template object + * using the feature_template table as cross reference * - * @param Category $category the related object to use as filter + * @param Template $template the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildFeatureQuery The current query, for fluid interface */ - public function filterByCategory($category, $comparison = Criteria::EQUAL) + public function filterByTemplate($template, $comparison = Criteria::EQUAL) { return $this - ->useFeatureCategoryQuery() - ->filterByCategory($category, $comparison) + ->useFeatureTemplateQuery() + ->filterByTemplate($template, $comparison) ->endUse(); } diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureTemplate.php similarity index 85% rename from core/lib/Thelia/Model/Base/FeatureCategory.php rename to core/lib/Thelia/Model/Base/FeatureTemplate.php index 035e077d2..bbccd9251 100644 --- a/core/lib/Thelia/Model/Base/FeatureCategory.php +++ b/core/lib/Thelia/Model/Base/FeatureTemplate.php @@ -16,20 +16,20 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Category as ChildCategory; -use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\Feature as ChildFeature; -use Thelia\Model\FeatureCategory as ChildFeatureCategory; -use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; use Thelia\Model\FeatureQuery as ChildFeatureQuery; -use Thelia\Model\Map\FeatureCategoryTableMap; +use Thelia\Model\FeatureTemplate as ChildFeatureTemplate; +use Thelia\Model\FeatureTemplateQuery as ChildFeatureTemplateQuery; +use Thelia\Model\Template as ChildTemplate; +use Thelia\Model\TemplateQuery as ChildTemplateQuery; +use Thelia\Model\Map\FeatureTemplateTableMap; -abstract class FeatureCategory implements ActiveRecordInterface +abstract class FeatureTemplate implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\FeatureCategoryTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\FeatureTemplateTableMap'; /** @@ -71,10 +71,10 @@ abstract class FeatureCategory implements ActiveRecordInterface protected $feature_id; /** - * The value for the category_id field. + * The value for the template_id field. * @var int */ - protected $category_id; + protected $template_id; /** * The value for the created_at field. @@ -88,16 +88,16 @@ abstract class FeatureCategory implements ActiveRecordInterface */ protected $updated_at; - /** - * @var Category - */ - protected $aCategory; - /** * @var Feature */ protected $aFeature; + /** + * @var Template + */ + protected $aTemplate; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -107,7 +107,7 @@ abstract class FeatureCategory implements ActiveRecordInterface protected $alreadyInSave = false; /** - * Initializes internal state of Thelia\Model\Base\FeatureCategory object. + * Initializes internal state of Thelia\Model\Base\FeatureTemplate object. */ public function __construct() { @@ -202,9 +202,9 @@ abstract class FeatureCategory implements ActiveRecordInterface } /** - * Compares this with another FeatureCategory instance. If - * obj is an instance of FeatureCategory, delegates to - * equals(FeatureCategory). Otherwise, returns false. + * Compares this with another FeatureTemplate instance. If + * obj is an instance of FeatureTemplate, delegates to + * equals(FeatureTemplate). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -285,7 +285,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return FeatureCategory The current object, for fluid interface + * @return FeatureTemplate The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -317,7 +317,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return FeatureCategory The current object, for fluid interface + * @return FeatureTemplate The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -383,14 +383,14 @@ abstract class FeatureCategory implements ActiveRecordInterface } /** - * Get the [category_id] column value. + * Get the [template_id] column value. * * @return int */ - public function getCategoryId() + public function getTemplateId() { - return $this->category_id; + return $this->template_id; } /** @@ -437,7 +437,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) */ public function setId($v) { @@ -447,7 +447,7 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = FeatureCategoryTableMap::ID; + $this->modifiedColumns[] = FeatureTemplateTableMap::ID; } @@ -458,7 +458,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * Set the value of [feature_id] column. * * @param int $v new value - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) */ public function setFeatureId($v) { @@ -468,7 +468,7 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($this->feature_id !== $v) { $this->feature_id = $v; - $this->modifiedColumns[] = FeatureCategoryTableMap::FEATURE_ID; + $this->modifiedColumns[] = FeatureTemplateTableMap::FEATURE_ID; } if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { @@ -480,36 +480,36 @@ abstract class FeatureCategory implements ActiveRecordInterface } // setFeatureId() /** - * Set the value of [category_id] column. + * Set the value of [template_id] column. * * @param int $v new value - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) */ - public function setCategoryId($v) + public function setTemplateId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = FeatureCategoryTableMap::CATEGORY_ID; + if ($this->template_id !== $v) { + $this->template_id = $v; + $this->modifiedColumns[] = FeatureTemplateTableMap::TEMPLATE_ID; } - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; + if ($this->aTemplate !== null && $this->aTemplate->getId() !== $v) { + $this->aTemplate = null; } return $this; - } // setCategoryId() + } // setTemplateId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -517,7 +517,7 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = FeatureCategoryTableMap::CREATED_AT; + $this->modifiedColumns[] = FeatureTemplateTableMap::CREATED_AT; } } // if either are not null @@ -530,7 +530,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -538,7 +538,7 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = FeatureCategoryTableMap::UPDATED_AT; + $this->modifiedColumns[] = FeatureTemplateTableMap::UPDATED_AT; } } // if either are not null @@ -583,22 +583,22 @@ abstract class FeatureCategory implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureTemplateTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureCategoryTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureTemplateTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)]; $this->feature_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->template_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -611,10 +611,10 @@ abstract class FeatureCategory implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\FeatureCategory object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\FeatureTemplate object", 0, $e); } } @@ -636,8 +636,8 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { $this->aFeature = null; } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; + if ($this->aTemplate !== null && $this->template_id !== $this->aTemplate->getId()) { + $this->aTemplate = null; } } // ensureConsistency @@ -662,13 +662,13 @@ abstract class FeatureCategory implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(FeatureTemplateTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildFeatureCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildFeatureTemplateQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -678,8 +678,8 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aCategory = null; $this->aFeature = null; + $this->aTemplate = null; } // if (deep) } @@ -689,8 +689,8 @@ abstract class FeatureCategory implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see FeatureCategory::setDeleted() - * @see FeatureCategory::isDeleted() + * @see FeatureTemplate::setDeleted() + * @see FeatureTemplate::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -699,12 +699,12 @@ abstract class FeatureCategory implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTemplateTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildFeatureCategoryQuery::create() + $deleteQuery = ChildFeatureTemplateQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -741,7 +741,7 @@ abstract class FeatureCategory implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTemplateTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -751,16 +751,16 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) { + if (!$this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -772,7 +772,7 @@ abstract class FeatureCategory implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - FeatureCategoryTableMap::addInstanceToPool($this); + FeatureTemplateTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -807,13 +807,6 @@ abstract class FeatureCategory implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - if ($this->aFeature !== null) { if ($this->aFeature->isModified() || $this->aFeature->isNew()) { $affectedRows += $this->aFeature->save($con); @@ -821,6 +814,13 @@ abstract class FeatureCategory implements ActiveRecordInterface $this->setFeature($this->aFeature); } + if ($this->aTemplate !== null) { + if ($this->aTemplate->isModified() || $this->aTemplate->isNew()) { + $affectedRows += $this->aTemplate->save($con); + } + $this->setTemplate($this->aTemplate); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -852,30 +852,30 @@ abstract class FeatureCategory implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = FeatureCategoryTableMap::ID; + $this->modifiedColumns[] = FeatureTemplateTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureCategoryTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureTemplateTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureCategoryTableMap::ID)) { + if ($this->isColumnModified(FeatureTemplateTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) { + if ($this->isColumnModified(FeatureTemplateTableMap::FEATURE_ID)) { $modifiedColumns[':p' . $index++] = 'FEATURE_ID'; } - if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) { + $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; } - if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) { + if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { + if ($this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO feature_category (%s) VALUES (%s)', + 'INSERT INTO feature_template (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -890,8 +890,8 @@ abstract class FeatureCategory implements ActiveRecordInterface case 'FEATURE_ID': $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); + case 'TEMPLATE_ID': + $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -945,7 +945,7 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = FeatureCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = FeatureTemplateTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -968,7 +968,7 @@ abstract class FeatureCategory implements ActiveRecordInterface return $this->getFeatureId(); break; case 2: - return $this->getCategoryId(); + return $this->getTemplateId(); break; case 3: return $this->getCreatedAt(); @@ -999,15 +999,15 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['FeatureTemplate'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()] = true; - $keys = FeatureCategoryTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['FeatureTemplate'][$this->getPrimaryKey()] = true; + $keys = FeatureTemplateTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getFeatureId(), - $keys[2] => $this->getCategoryId(), + $keys[2] => $this->getTemplateId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -1018,12 +1018,12 @@ abstract class FeatureCategory implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } if (null !== $this->aFeature) { $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aTemplate) { + $result['Template'] = $this->aTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1042,7 +1042,7 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = FeatureCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = FeatureTemplateTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1065,7 +1065,7 @@ abstract class FeatureCategory implements ActiveRecordInterface $this->setFeatureId($value); break; case 2: - $this->setCategoryId($value); + $this->setTemplateId($value); break; case 3: $this->setCreatedAt($value); @@ -1095,11 +1095,11 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = FeatureCategoryTableMap::getFieldNames($keyType); + $keys = FeatureTemplateTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -1111,13 +1111,13 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(FeatureCategoryTableMap::DATABASE_NAME); + $criteria = new Criteria(FeatureTemplateTableMap::DATABASE_NAME); - if ($this->isColumnModified(FeatureCategoryTableMap::ID)) $criteria->add(FeatureCategoryTableMap::ID, $this->id); - if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) $criteria->add(FeatureCategoryTableMap::FEATURE_ID, $this->feature_id); - if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) $criteria->add(FeatureCategoryTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) $criteria->add(FeatureCategoryTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) $criteria->add(FeatureCategoryTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(FeatureTemplateTableMap::ID)) $criteria->add(FeatureTemplateTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureTemplateTableMap::FEATURE_ID)) $criteria->add(FeatureTemplateTableMap::FEATURE_ID, $this->feature_id); + if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) $criteria->add(FeatureTemplateTableMap::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) $criteria->add(FeatureTemplateTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) $criteria->add(FeatureTemplateTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1132,8 +1132,8 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(FeatureCategoryTableMap::DATABASE_NAME); - $criteria->add(FeatureCategoryTableMap::ID, $this->id); + $criteria = new Criteria(FeatureTemplateTableMap::DATABASE_NAME); + $criteria->add(FeatureTemplateTableMap::ID, $this->id); return $criteria; } @@ -1174,7 +1174,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\FeatureCategory (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\FeatureTemplate (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1182,7 +1182,7 @@ abstract class FeatureCategory implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setFeatureId($this->getFeatureId()); - $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setTemplateId($this->getTemplateId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1200,7 +1200,7 @@ abstract class FeatureCategory implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\FeatureCategory Clone of current object. + * @return \Thelia\Model\FeatureTemplate Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1213,62 +1213,11 @@ abstract class FeatureCategory implements ActiveRecordInterface return $copyObj; } - /** - * Declares an association between this object and a ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addFeatureCategory($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addFeatureCategories($this); - */ - } - - return $this->aCategory; - } - /** * Declares an association between this object and a ChildFeature object. * * @param ChildFeature $v - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) * @throws PropelException */ public function setFeature(ChildFeature $v = null) @@ -1284,7 +1233,7 @@ abstract class FeatureCategory implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildFeature object, it will not be re-added. if ($v !== null) { - $v->addFeatureCategory($this); + $v->addFeatureTemplate($this); } @@ -1308,13 +1257,64 @@ abstract class FeatureCategory implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aFeature->addFeatureCategories($this); + $this->aFeature->addFeatureTemplates($this); */ } return $this->aFeature; } + /** + * Declares an association between this object and a ChildTemplate object. + * + * @param ChildTemplate $v + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) + * @throws PropelException + */ + public function setTemplate(ChildTemplate $v = null) + { + if ($v === null) { + $this->setTemplateId(NULL); + } else { + $this->setTemplateId($v->getId()); + } + + $this->aTemplate = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildTemplate object, it will not be re-added. + if ($v !== null) { + $v->addFeatureTemplate($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTemplate object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTemplate The associated ChildTemplate object. + * @throws PropelException + */ + public function getTemplate(ConnectionInterface $con = null) + { + if ($this->aTemplate === null && ($this->template_id !== null)) { + $this->aTemplate = ChildTemplateQuery::create()->findPk($this->template_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aTemplate->addFeatureTemplates($this); + */ + } + + return $this->aTemplate; + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1322,7 +1322,7 @@ abstract class FeatureCategory implements ActiveRecordInterface { $this->id = null; $this->feature_id = null; - $this->category_id = null; + $this->template_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1346,8 +1346,8 @@ abstract class FeatureCategory implements ActiveRecordInterface if ($deep) { } // if ($deep) - $this->aCategory = null; $this->aFeature = null; + $this->aTemplate = null; } /** @@ -1357,7 +1357,7 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(FeatureCategoryTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(FeatureTemplateTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1365,11 +1365,11 @@ abstract class FeatureCategory implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildFeatureCategory The current object (for fluent API support) + * @return ChildFeatureTemplate The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = FeatureCategoryTableMap::UPDATED_AT; + $this->modifiedColumns[] = FeatureTemplateTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php similarity index 69% rename from core/lib/Thelia/Model/Base/FeatureCategoryQuery.php rename to core/lib/Thelia/Model/Base/FeatureTemplateQuery.php index b9c9a67be..c99c1305f 100644 --- a/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php @@ -12,84 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\FeatureCategory as ChildFeatureCategory; -use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; -use Thelia\Model\Map\FeatureCategoryTableMap; +use Thelia\Model\FeatureTemplate as ChildFeatureTemplate; +use Thelia\Model\FeatureTemplateQuery as ChildFeatureTemplateQuery; +use Thelia\Model\Map\FeatureTemplateTableMap; /** - * Base class that represents a query for the 'feature_category' table. + * Base class that represents a query for the 'feature_template' table. * * * - * @method ChildFeatureCategoryQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildFeatureCategoryQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column - * @method ChildFeatureCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column - * @method ChildFeatureCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildFeatureCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildFeatureTemplateQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildFeatureTemplateQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column + * @method ChildFeatureTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column + * @method ChildFeatureTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ChildFeatureTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * - * @method ChildFeatureCategoryQuery groupById() Group by the id column - * @method ChildFeatureCategoryQuery groupByFeatureId() Group by the feature_id column - * @method ChildFeatureCategoryQuery groupByCategoryId() Group by the category_id column - * @method ChildFeatureCategoryQuery groupByCreatedAt() Group by the created_at column - * @method ChildFeatureCategoryQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildFeatureTemplateQuery groupById() Group by the id column + * @method ChildFeatureTemplateQuery groupByFeatureId() Group by the feature_id column + * @method ChildFeatureTemplateQuery groupByTemplateId() Group by the template_id column + * @method ChildFeatureTemplateQuery groupByCreatedAt() Group by the created_at column + * @method ChildFeatureTemplateQuery groupByUpdatedAt() Group by the updated_at column * - * @method ChildFeatureCategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildFeatureCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildFeatureCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildFeatureTemplateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildFeatureTemplateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildFeatureTemplateQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildFeatureCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation - * @method ChildFeatureCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation - * @method ChildFeatureCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation + * @method ChildFeatureTemplateQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation + * @method ChildFeatureTemplateQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation + * @method ChildFeatureTemplateQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation * - * @method ChildFeatureCategoryQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation - * @method ChildFeatureCategoryQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation - * @method ChildFeatureCategoryQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation + * @method ChildFeatureTemplateQuery leftJoinTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the Template relation + * @method ChildFeatureTemplateQuery rightJoinTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Template relation + * @method ChildFeatureTemplateQuery innerJoinTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the Template relation * - * @method ChildFeatureCategory findOne(ConnectionInterface $con = null) Return the first ChildFeatureCategory matching the query - * @method ChildFeatureCategory findOneOrCreate(ConnectionInterface $con = null) Return the first ChildFeatureCategory matching the query, or a new ChildFeatureCategory object populated from the query conditions when no match is found + * @method ChildFeatureTemplate findOne(ConnectionInterface $con = null) Return the first ChildFeatureTemplate matching the query + * @method ChildFeatureTemplate findOneOrCreate(ConnectionInterface $con = null) Return the first ChildFeatureTemplate matching the query, or a new ChildFeatureTemplate object populated from the query conditions when no match is found * - * @method ChildFeatureCategory findOneById(int $id) Return the first ChildFeatureCategory filtered by the id column - * @method ChildFeatureCategory findOneByFeatureId(int $feature_id) Return the first ChildFeatureCategory filtered by the feature_id column - * @method ChildFeatureCategory findOneByCategoryId(int $category_id) Return the first ChildFeatureCategory filtered by the category_id column - * @method ChildFeatureCategory findOneByCreatedAt(string $created_at) Return the first ChildFeatureCategory filtered by the created_at column - * @method ChildFeatureCategory findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureCategory filtered by the updated_at column + * @method ChildFeatureTemplate findOneById(int $id) Return the first ChildFeatureTemplate filtered by the id column + * @method ChildFeatureTemplate findOneByFeatureId(int $feature_id) Return the first ChildFeatureTemplate filtered by the feature_id column + * @method ChildFeatureTemplate findOneByTemplateId(int $template_id) Return the first ChildFeatureTemplate filtered by the template_id column + * @method ChildFeatureTemplate findOneByCreatedAt(string $created_at) Return the first ChildFeatureTemplate filtered by the created_at column + * @method ChildFeatureTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureTemplate filtered by the updated_at column * - * @method array findById(int $id) Return ChildFeatureCategory objects filtered by the id column - * @method array findByFeatureId(int $feature_id) Return ChildFeatureCategory objects filtered by the feature_id column - * @method array findByCategoryId(int $category_id) Return ChildFeatureCategory objects filtered by the category_id column - * @method array findByCreatedAt(string $created_at) Return ChildFeatureCategory objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureCategory objects filtered by the updated_at column + * @method array findById(int $id) Return ChildFeatureTemplate objects filtered by the id column + * @method array findByFeatureId(int $feature_id) Return ChildFeatureTemplate objects filtered by the feature_id column + * @method array findByTemplateId(int $template_id) Return ChildFeatureTemplate objects filtered by the template_id column + * @method array findByCreatedAt(string $created_at) Return ChildFeatureTemplate objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureTemplate objects filtered by the updated_at column * */ -abstract class FeatureCategoryQuery extends ModelCriteria +abstract class FeatureTemplateQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\FeatureCategoryQuery object. + * Initializes internal state of \Thelia\Model\Base\FeatureTemplateQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\FeatureCategory', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\FeatureTemplate', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildFeatureCategoryQuery object. + * Returns a new ChildFeatureTemplateQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildFeatureCategoryQuery + * @return ChildFeatureTemplateQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\FeatureCategoryQuery) { + if ($criteria instanceof \Thelia\Model\FeatureTemplateQuery) { return $criteria; } - $query = new \Thelia\Model\FeatureCategoryQuery(); + $query = new \Thelia\Model\FeatureTemplateQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -112,19 +112,19 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter + * @return ChildFeatureTemplate|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = FeatureTemplateTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(FeatureTemplateTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,11 +143,11 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildFeatureCategory A model object, or null if the key is not found + * @return ChildFeatureTemplate A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, FEATURE_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM feature_category WHERE ID = :p0'; + $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -158,9 +158,9 @@ abstract class FeatureCategoryQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildFeatureCategory(); + $obj = new ChildFeatureTemplate(); $obj->hydrate($row); - FeatureCategoryTableMap::addInstanceToPool($obj, (string) $key); + FeatureTemplateTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -173,7 +173,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter + * @return ChildFeatureTemplate|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -215,12 +215,12 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FeatureCategoryTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(FeatureTemplateTableMap::ID, $key, Criteria::EQUAL); } /** @@ -228,12 +228,12 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FeatureCategoryTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(FeatureTemplateTableMap::ID, $keys, Criteria::IN); } /** @@ -252,18 +252,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -274,7 +274,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::ID, $id, $comparison); + return $this->addUsingAlias(FeatureTemplateTableMap::ID, $id, $comparison); } /** @@ -295,18 +295,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterByFeatureId($featureId = null, $comparison = null) { if (is_array($featureId)) { $useMinMax = false; if (isset($featureId['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -317,39 +317,39 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId, $comparison); + return $this->addUsingAlias(FeatureTemplateTableMap::FEATURE_ID, $featureId, $comparison); } /** - * Filter the query on the category_id column + * Filter the query on the template_id column * * Example usage: * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByTemplateId(1234); // WHERE template_id = 1234 + * $query->filterByTemplateId(array(12, 34)); // WHERE template_id IN (12, 34) + * $query->filterByTemplateId(array('min' => 12)); // WHERE template_id > 12 * * - * @see filterByCategory() + * @see filterByTemplate() * - * @param mixed $categoryId The value to use as filter. + * @param mixed $templateId The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ - public function filterByCategoryId($categoryId = null, $comparison = null) + public function filterByTemplateId($templateId = null, $comparison = null) { - if (is_array($categoryId)) { + if (is_array($templateId)) { $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + if (isset($templateId['min'])) { + $this->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $templateId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($categoryId['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + if (isset($templateId['max'])) { + $this->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $templateId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -360,7 +360,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $templateId, $comparison); } /** @@ -381,18 +381,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterByCreatedAt($createdAt = null, $comparison = null) { if (is_array($createdAt)) { $useMinMax = false; if (isset($createdAt['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -403,7 +403,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FeatureTemplateTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -424,18 +424,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterByUpdatedAt($updatedAt = null, $comparison = null) { if (is_array($updatedAt)) { $useMinMax = false; if (isset($updatedAt['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTemplateTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -446,82 +446,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildFeatureCategoryQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildFeatureCategoryQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + return $this->addUsingAlias(FeatureTemplateTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -530,20 +455,20 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function filterByFeature($feature, $comparison = null) { if ($feature instanceof \Thelia\Model\Feature) { return $this - ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->getId(), $comparison); + ->addUsingAlias(FeatureTemplateTableMap::FEATURE_ID, $feature->getId(), $comparison); } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureTemplateTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } @@ -555,7 +480,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -600,23 +525,98 @@ abstract class FeatureCategoryQuery extends ModelCriteria } /** - * Exclude object from result + * Filter the query by a related \Thelia\Model\Template object * - * @param ChildFeatureCategory $featureCategory Object to remove from the list of results + * @param \Thelia\Model\Template|ObjectCollection $template The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ - public function prune($featureCategory = null) + public function filterByTemplate($template, $comparison = null) { - if ($featureCategory) { - $this->addUsingAlias(FeatureCategoryTableMap::ID, $featureCategory->getId(), Criteria::NOT_EQUAL); + if ($template instanceof \Thelia\Model\Template) { + return $this + ->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $template->getId(), $comparison); + } elseif ($template instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $template->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByTemplate() only accepts arguments of type \Thelia\Model\Template or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Template relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFeatureTemplateQuery The current query, for fluid interface + */ + public function joinTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Template'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Template'); } return $this; } /** - * Deletes all rows from the feature_category table. + * Use the Template relation Template object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query + */ + public function useTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Template', '\Thelia\Model\TemplateQuery'); + } + + /** + * Exclude object from result + * + * @param ChildFeatureTemplate $featureTemplate Object to remove from the list of results + * + * @return ChildFeatureTemplateQuery The current query, for fluid interface + */ + public function prune($featureTemplate = null) + { + if ($featureTemplate) { + $this->addUsingAlias(FeatureTemplateTableMap::ID, $featureTemplate->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the feature_template table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -624,7 +624,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTemplateTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -635,8 +635,8 @@ abstract class FeatureCategoryQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - FeatureCategoryTableMap::clearInstancePool(); - FeatureCategoryTableMap::clearRelatedInstancePool(); + FeatureTemplateTableMap::clearInstancePool(); + FeatureTemplateTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -648,9 +648,9 @@ abstract class FeatureCategoryQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildFeatureCategory or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildFeatureTemplate or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildFeatureCategory object or primary key or array of primary keys + * @param mixed $values Criteria or ChildFeatureTemplate object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -661,13 +661,13 @@ abstract class FeatureCategoryQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTemplateTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(FeatureCategoryTableMap::DATABASE_NAME); + $criteria->setDbName(FeatureTemplateTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -677,10 +677,10 @@ abstract class FeatureCategoryQuery extends ModelCriteria $con->beginTransaction(); - FeatureCategoryTableMap::removeInstanceFromPool($criteria); + FeatureTemplateTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - FeatureCategoryTableMap::clearRelatedInstancePool(); + FeatureTemplateTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -697,11 +697,11 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function recentlyUpdated($nbDays = 7) { - return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(FeatureTemplateTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -709,51 +709,51 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function recentlyCreated($nbDays = 7) { - return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(FeatureTemplateTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(FeatureTemplateTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(FeatureTemplateTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(FeatureTemplateTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureTemplateQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(FeatureTemplateTableMap::CREATED_AT); } -} // FeatureCategoryQuery +} // FeatureTemplateQuery diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php index 1c11103af..59836e27d 100644 --- a/core/lib/Thelia/Model/Base/Lang.php +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Exception\PropelException; @@ -18,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Lang as ChildLang; use Thelia\Model\LangQuery as ChildLangQuery; +use Thelia\Model\Order as ChildOrder; +use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\LangTableMap; abstract class Lang implements ActiveRecordInterface @@ -144,6 +147,12 @@ abstract class Lang implements ActiveRecordInterface */ protected $updated_at; + /** + * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. + */ + protected $collOrders; + protected $collOrdersPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -152,6 +161,12 @@ abstract class Lang implements ActiveRecordInterface */ protected $alreadyInSave = false; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $ordersScheduledForDeletion = null; + /** * Initializes internal state of Thelia\Model\Base\Lang object. */ @@ -1060,6 +1075,8 @@ abstract class Lang implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->collOrders = null; + } // if (deep) } @@ -1193,6 +1210,23 @@ abstract class Lang implements ActiveRecordInterface $this->resetModified(); } + if ($this->ordersScheduledForDeletion !== null) { + if (!$this->ordersScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersScheduledForDeletion = null; + } + } + + if ($this->collOrders !== null) { + foreach ($this->collOrders as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -1444,10 +1478,11 @@ abstract class Lang implements ActiveRecordInterface * Defaults to TableMap::TYPE_PHPNAME. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. * * @return array an associative array containing the field names (as keys) and field values */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['Lang'][$this->getPrimaryKey()])) { return '*RECURSION*'; @@ -1477,6 +1512,11 @@ abstract class Lang implements ActiveRecordInterface $result[$key] = $virtualColumn; } + if ($includeForeignObjects) { + if (null !== $this->collOrders) { + $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } return $result; } @@ -1697,6 +1737,20 @@ abstract class Lang implements ActiveRecordInterface $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getOrders() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrder($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value @@ -1725,6 +1779,415 @@ abstract class Lang implements ActiveRecordInterface return $copyObj; } + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('Order' == $relationName) { + return $this->initOrders(); + } + } + + /** + * Clears out the collOrders collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrders() + */ + public function clearOrders() + { + $this->collOrders = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrders collection loaded partially. + */ + public function resetPartialOrders($v = true) + { + $this->collOrdersPartial = $v; + } + + /** + * Initializes the collOrders collection. + * + * By default this just sets the collOrders collection to an empty array (like clearcollOrders()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrders($overrideExisting = true) + { + if (null !== $this->collOrders && !$overrideExisting) { + return; + } + $this->collOrders = new ObjectCollection(); + $this->collOrders->setModel('\Thelia\Model\Order'); + } + + /** + * Gets an array of ChildOrder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildLang is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects + * @throws PropelException + */ + public function getOrders($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrdersPartial && !$this->isNew(); + if (null === $this->collOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrders) { + // return empty collection + $this->initOrders(); + } else { + $collOrders = ChildOrderQuery::create(null, $criteria) + ->filterByLang($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrdersPartial && count($collOrders)) { + $this->initOrders(false); + + foreach ($collOrders as $obj) { + if (false == $this->collOrders->contains($obj)) { + $this->collOrders->append($obj); + } + } + + $this->collOrdersPartial = true; + } + + $collOrders->getInternalIterator()->rewind(); + + return $collOrders; + } + + if ($partial && $this->collOrders) { + foreach ($this->collOrders as $obj) { + if ($obj->isNew()) { + $collOrders[] = $obj; + } + } + } + + $this->collOrders = $collOrders; + $this->collOrdersPartial = false; + } + } + + return $this->collOrders; + } + + /** + * Sets a collection of Order objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $orders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildLang The current object (for fluent API support) + */ + public function setOrders(Collection $orders, ConnectionInterface $con = null) + { + $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); + + + $this->ordersScheduledForDeletion = $ordersToDelete; + + foreach ($ordersToDelete as $orderRemoved) { + $orderRemoved->setLang(null); + } + + $this->collOrders = null; + foreach ($orders as $order) { + $this->addOrder($order); + } + + $this->collOrders = $orders; + $this->collOrdersPartial = false; + + return $this; + } + + /** + * Returns the number of related Order objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Order objects. + * @throws PropelException + */ + public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrdersPartial && !$this->isNew(); + if (null === $this->collOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrders) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrders()); + } + + $query = ChildOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByLang($this) + ->count($con); + } + + return count($this->collOrders); + } + + /** + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. + * + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function addOrder(ChildOrder $l) + { + if ($this->collOrders === null) { + $this->initOrders(); + $this->collOrdersPartial = true; + } + + if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrder($l); + } + + return $this; + } + + /** + * @param Order $order The order object to add. + */ + protected function doAddOrder($order) + { + $this->collOrders[]= $order; + $order->setLang($this); + } + + /** + * @param Order $order The order object to remove. + * @return ChildLang The current object (for fluent API support) + */ + public function removeOrder($order) + { + if ($this->getOrders()->contains($order)) { + $this->collOrders->remove($this->collOrders->search($order)); + if (null === $this->ordersScheduledForDeletion) { + $this->ordersScheduledForDeletion = clone $this->collOrders; + $this->ordersScheduledForDeletion->clear(); + } + $this->ordersScheduledForDeletion[]= clone $order; + $order->setLang(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1764,8 +2227,17 @@ abstract class Lang implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collOrders) { + foreach ($this->collOrders as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) + if ($this->collOrders instanceof Collection) { + $this->collOrders->clearIterator(); + } + $this->collOrders = null; } /** diff --git a/core/lib/Thelia/Model/Base/LangQuery.php b/core/lib/Thelia/Model/Base/LangQuery.php index 2fabec9ee..045ee0887 100644 --- a/core/lib/Thelia/Model/Base/LangQuery.php +++ b/core/lib/Thelia/Model/Base/LangQuery.php @@ -7,6 +7,9 @@ use \PDO; use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveQuery\ModelJoin; +use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; use Thelia\Model\Lang as ChildLang; @@ -54,6 +57,10 @@ use Thelia\Model\Map\LangTableMap; * @method ChildLangQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildLangQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildLangQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation + * @method ChildLangQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation + * @method ChildLangQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation + * * @method ChildLang findOne(ConnectionInterface $con = null) Return the first ChildLang matching the query * @method ChildLang findOneOrCreate(ConnectionInterface $con = null) Return the first ChildLang matching the query, or a new ChildLang object populated from the query conditions when no match is found * @@ -764,6 +771,79 @@ abstract class LangQuery extends ModelCriteria return $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildLangQuery The current query, for fluid interface + */ + public function filterByOrder($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(LangTableMap::ID, $order->getLangId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + return $this + ->useOrderQuery() + ->filterByPrimaryKeys($order->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Order relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildLangQuery The current query, for fluid interface + */ + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Order'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Order'); + } + + return $this; + } + + /** + * Use the Order relation Order object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); + } + /** * Exclude object from result * diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index 9cc89381a..88080dbe2 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -17,12 +17,18 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\GroupModule as ChildGroupModule; use Thelia\Model\GroupModuleQuery as ChildGroupModuleQuery; use Thelia\Model\Module as ChildModule; use Thelia\Model\ModuleI18n as ChildModuleI18n; use Thelia\Model\ModuleI18nQuery as ChildModuleI18nQuery; +use Thelia\Model\ModuleImage as ChildModuleImage; +use Thelia\Model\ModuleImageQuery as ChildModuleImageQuery; use Thelia\Model\ModuleQuery as ChildModuleQuery; +use Thelia\Model\Order as ChildOrder; +use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\ModuleTableMap; abstract class Module implements ActiveRecordInterface @@ -107,12 +113,36 @@ abstract class Module implements ActiveRecordInterface */ protected $updated_at; + /** + * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. + */ + protected $collOrdersRelatedByPaymentModuleId; + protected $collOrdersRelatedByPaymentModuleIdPartial; + + /** + * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. + */ + protected $collOrdersRelatedByDeliveryModuleId; + protected $collOrdersRelatedByDeliveryModuleIdPartial; + + /** + * @var ObjectCollection|ChildAreaDeliveryModule[] Collection to store aggregation of ChildAreaDeliveryModule objects. + */ + protected $collAreaDeliveryModules; + protected $collAreaDeliveryModulesPartial; + /** * @var ObjectCollection|ChildGroupModule[] Collection to store aggregation of ChildGroupModule objects. */ protected $collGroupModules; protected $collGroupModulesPartial; + /** + * @var ObjectCollection|ChildModuleImage[] Collection to store aggregation of ChildModuleImage objects. + */ + protected $collModuleImages; + protected $collModuleImagesPartial; + /** * @var ObjectCollection|ChildModuleI18n[] Collection to store aggregation of ChildModuleI18n objects. */ @@ -141,12 +171,36 @@ abstract class Module implements ActiveRecordInterface */ protected $currentTranslations; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $ordersRelatedByPaymentModuleIdScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $ordersRelatedByDeliveryModuleIdScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $areaDeliveryModulesScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection */ protected $groupModulesScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $moduleImagesScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -816,8 +870,16 @@ abstract class Module implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->collOrdersRelatedByPaymentModuleId = null; + + $this->collOrdersRelatedByDeliveryModuleId = null; + + $this->collAreaDeliveryModules = null; + $this->collGroupModules = null; + $this->collModuleImages = null; + $this->collModuleI18ns = null; } // if (deep) @@ -953,6 +1015,57 @@ abstract class Module implements ActiveRecordInterface $this->resetModified(); } + if ($this->ordersRelatedByPaymentModuleIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByPaymentModuleIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByPaymentModuleIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion = null; + } + } + + if ($this->collOrdersRelatedByPaymentModuleId !== null) { + foreach ($this->collOrdersRelatedByPaymentModuleId as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ordersRelatedByDeliveryModuleIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByDeliveryModuleIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByDeliveryModuleIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion = null; + } + } + + if ($this->collOrdersRelatedByDeliveryModuleId !== null) { + foreach ($this->collOrdersRelatedByDeliveryModuleId as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->areaDeliveryModulesScheduledForDeletion !== null) { + if (!$this->areaDeliveryModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AreaDeliveryModuleQuery::create() + ->filterByPrimaryKeys($this->areaDeliveryModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->areaDeliveryModulesScheduledForDeletion = null; + } + } + + if ($this->collAreaDeliveryModules !== null) { + foreach ($this->collAreaDeliveryModules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->groupModulesScheduledForDeletion !== null) { if (!$this->groupModulesScheduledForDeletion->isEmpty()) { \Thelia\Model\GroupModuleQuery::create() @@ -970,6 +1083,23 @@ abstract class Module implements ActiveRecordInterface } } + if ($this->moduleImagesScheduledForDeletion !== null) { + if (!$this->moduleImagesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ModuleImageQuery::create() + ->filterByPrimaryKeys($this->moduleImagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->moduleImagesScheduledForDeletion = null; + } + } + + if ($this->collModuleImages !== null) { + foreach ($this->collModuleImages as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->moduleI18nsScheduledForDeletion !== null) { if (!$this->moduleI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\ModuleI18nQuery::create() @@ -1203,9 +1333,21 @@ abstract class Module implements ActiveRecordInterface } if ($includeForeignObjects) { + if (null !== $this->collOrdersRelatedByPaymentModuleId) { + $result['OrdersRelatedByPaymentModuleId'] = $this->collOrdersRelatedByPaymentModuleId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collOrdersRelatedByDeliveryModuleId) { + $result['OrdersRelatedByDeliveryModuleId'] = $this->collOrdersRelatedByDeliveryModuleId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collAreaDeliveryModules) { + $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collGroupModules) { $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collModuleImages) { + $result['ModuleImages'] = $this->collModuleImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collModuleI18ns) { $result['ModuleI18ns'] = $this->collModuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1394,12 +1536,36 @@ abstract class Module implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); + foreach ($this->getOrdersRelatedByPaymentModuleId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderRelatedByPaymentModuleId($relObj->copy($deepCopy)); + } + } + + foreach ($this->getOrdersRelatedByDeliveryModuleId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderRelatedByDeliveryModuleId($relObj->copy($deepCopy)); + } + } + + foreach ($this->getAreaDeliveryModules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAreaDeliveryModule($relObj->copy($deepCopy)); + } + } + foreach ($this->getGroupModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addGroupModule($relObj->copy($deepCopy)); } } + foreach ($this->getModuleImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addModuleImage($relObj->copy($deepCopy)); + } + } + foreach ($this->getModuleI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addModuleI18n($relObj->copy($deepCopy)); @@ -1447,14 +1613,1005 @@ abstract class Module implements ActiveRecordInterface */ public function initRelation($relationName) { + if ('OrderRelatedByPaymentModuleId' == $relationName) { + return $this->initOrdersRelatedByPaymentModuleId(); + } + if ('OrderRelatedByDeliveryModuleId' == $relationName) { + return $this->initOrdersRelatedByDeliveryModuleId(); + } + if ('AreaDeliveryModule' == $relationName) { + return $this->initAreaDeliveryModules(); + } if ('GroupModule' == $relationName) { return $this->initGroupModules(); } + if ('ModuleImage' == $relationName) { + return $this->initModuleImages(); + } if ('ModuleI18n' == $relationName) { return $this->initModuleI18ns(); } } + /** + * Clears out the collOrdersRelatedByPaymentModuleId collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrdersRelatedByPaymentModuleId() + */ + public function clearOrdersRelatedByPaymentModuleId() + { + $this->collOrdersRelatedByPaymentModuleId = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrdersRelatedByPaymentModuleId collection loaded partially. + */ + public function resetPartialOrdersRelatedByPaymentModuleId($v = true) + { + $this->collOrdersRelatedByPaymentModuleIdPartial = $v; + } + + /** + * Initializes the collOrdersRelatedByPaymentModuleId collection. + * + * By default this just sets the collOrdersRelatedByPaymentModuleId collection to an empty array (like clearcollOrdersRelatedByPaymentModuleId()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrdersRelatedByPaymentModuleId($overrideExisting = true) + { + if (null !== $this->collOrdersRelatedByPaymentModuleId && !$overrideExisting) { + return; + } + $this->collOrdersRelatedByPaymentModuleId = new ObjectCollection(); + $this->collOrdersRelatedByPaymentModuleId->setModel('\Thelia\Model\Order'); + } + + /** + * Gets an array of ChildOrder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects + * @throws PropelException + */ + public function getOrdersRelatedByPaymentModuleId($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByPaymentModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByPaymentModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByPaymentModuleId) { + // return empty collection + $this->initOrdersRelatedByPaymentModuleId(); + } else { + $collOrdersRelatedByPaymentModuleId = ChildOrderQuery::create(null, $criteria) + ->filterByModuleRelatedByPaymentModuleId($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrdersRelatedByPaymentModuleIdPartial && count($collOrdersRelatedByPaymentModuleId)) { + $this->initOrdersRelatedByPaymentModuleId(false); + + foreach ($collOrdersRelatedByPaymentModuleId as $obj) { + if (false == $this->collOrdersRelatedByPaymentModuleId->contains($obj)) { + $this->collOrdersRelatedByPaymentModuleId->append($obj); + } + } + + $this->collOrdersRelatedByPaymentModuleIdPartial = true; + } + + $collOrdersRelatedByPaymentModuleId->getInternalIterator()->rewind(); + + return $collOrdersRelatedByPaymentModuleId; + } + + if ($partial && $this->collOrdersRelatedByPaymentModuleId) { + foreach ($this->collOrdersRelatedByPaymentModuleId as $obj) { + if ($obj->isNew()) { + $collOrdersRelatedByPaymentModuleId[] = $obj; + } + } + } + + $this->collOrdersRelatedByPaymentModuleId = $collOrdersRelatedByPaymentModuleId; + $this->collOrdersRelatedByPaymentModuleIdPartial = false; + } + } + + return $this->collOrdersRelatedByPaymentModuleId; + } + + /** + * Sets a collection of OrderRelatedByPaymentModuleId objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $ordersRelatedByPaymentModuleId A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setOrdersRelatedByPaymentModuleId(Collection $ordersRelatedByPaymentModuleId, ConnectionInterface $con = null) + { + $ordersRelatedByPaymentModuleIdToDelete = $this->getOrdersRelatedByPaymentModuleId(new Criteria(), $con)->diff($ordersRelatedByPaymentModuleId); + + + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion = $ordersRelatedByPaymentModuleIdToDelete; + + foreach ($ordersRelatedByPaymentModuleIdToDelete as $orderRelatedByPaymentModuleIdRemoved) { + $orderRelatedByPaymentModuleIdRemoved->setModuleRelatedByPaymentModuleId(null); + } + + $this->collOrdersRelatedByPaymentModuleId = null; + foreach ($ordersRelatedByPaymentModuleId as $orderRelatedByPaymentModuleId) { + $this->addOrderRelatedByPaymentModuleId($orderRelatedByPaymentModuleId); + } + + $this->collOrdersRelatedByPaymentModuleId = $ordersRelatedByPaymentModuleId; + $this->collOrdersRelatedByPaymentModuleIdPartial = false; + + return $this; + } + + /** + * Returns the number of related Order objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Order objects. + * @throws PropelException + */ + public function countOrdersRelatedByPaymentModuleId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByPaymentModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByPaymentModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByPaymentModuleId) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrdersRelatedByPaymentModuleId()); + } + + $query = ChildOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModuleRelatedByPaymentModuleId($this) + ->count($con); + } + + return count($this->collOrdersRelatedByPaymentModuleId); + } + + /** + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. + * + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addOrderRelatedByPaymentModuleId(ChildOrder $l) + { + if ($this->collOrdersRelatedByPaymentModuleId === null) { + $this->initOrdersRelatedByPaymentModuleId(); + $this->collOrdersRelatedByPaymentModuleIdPartial = true; + } + + if (!in_array($l, $this->collOrdersRelatedByPaymentModuleId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByPaymentModuleId($l); + } + + return $this; + } + + /** + * @param OrderRelatedByPaymentModuleId $orderRelatedByPaymentModuleId The orderRelatedByPaymentModuleId object to add. + */ + protected function doAddOrderRelatedByPaymentModuleId($orderRelatedByPaymentModuleId) + { + $this->collOrdersRelatedByPaymentModuleId[]= $orderRelatedByPaymentModuleId; + $orderRelatedByPaymentModuleId->setModuleRelatedByPaymentModuleId($this); + } + + /** + * @param OrderRelatedByPaymentModuleId $orderRelatedByPaymentModuleId The orderRelatedByPaymentModuleId object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeOrderRelatedByPaymentModuleId($orderRelatedByPaymentModuleId) + { + if ($this->getOrdersRelatedByPaymentModuleId()->contains($orderRelatedByPaymentModuleId)) { + $this->collOrdersRelatedByPaymentModuleId->remove($this->collOrdersRelatedByPaymentModuleId->search($orderRelatedByPaymentModuleId)); + if (null === $this->ordersRelatedByPaymentModuleIdScheduledForDeletion) { + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion = clone $this->collOrdersRelatedByPaymentModuleId; + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion->clear(); + } + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion[]= clone $orderRelatedByPaymentModuleId; + $orderRelatedByPaymentModuleId->setModuleRelatedByPaymentModuleId(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + /** + * Clears out the collOrdersRelatedByDeliveryModuleId collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrdersRelatedByDeliveryModuleId() + */ + public function clearOrdersRelatedByDeliveryModuleId() + { + $this->collOrdersRelatedByDeliveryModuleId = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrdersRelatedByDeliveryModuleId collection loaded partially. + */ + public function resetPartialOrdersRelatedByDeliveryModuleId($v = true) + { + $this->collOrdersRelatedByDeliveryModuleIdPartial = $v; + } + + /** + * Initializes the collOrdersRelatedByDeliveryModuleId collection. + * + * By default this just sets the collOrdersRelatedByDeliveryModuleId collection to an empty array (like clearcollOrdersRelatedByDeliveryModuleId()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrdersRelatedByDeliveryModuleId($overrideExisting = true) + { + if (null !== $this->collOrdersRelatedByDeliveryModuleId && !$overrideExisting) { + return; + } + $this->collOrdersRelatedByDeliveryModuleId = new ObjectCollection(); + $this->collOrdersRelatedByDeliveryModuleId->setModel('\Thelia\Model\Order'); + } + + /** + * Gets an array of ChildOrder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects + * @throws PropelException + */ + public function getOrdersRelatedByDeliveryModuleId($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByDeliveryModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryModuleId) { + // return empty collection + $this->initOrdersRelatedByDeliveryModuleId(); + } else { + $collOrdersRelatedByDeliveryModuleId = ChildOrderQuery::create(null, $criteria) + ->filterByModuleRelatedByDeliveryModuleId($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrdersRelatedByDeliveryModuleIdPartial && count($collOrdersRelatedByDeliveryModuleId)) { + $this->initOrdersRelatedByDeliveryModuleId(false); + + foreach ($collOrdersRelatedByDeliveryModuleId as $obj) { + if (false == $this->collOrdersRelatedByDeliveryModuleId->contains($obj)) { + $this->collOrdersRelatedByDeliveryModuleId->append($obj); + } + } + + $this->collOrdersRelatedByDeliveryModuleIdPartial = true; + } + + $collOrdersRelatedByDeliveryModuleId->getInternalIterator()->rewind(); + + return $collOrdersRelatedByDeliveryModuleId; + } + + if ($partial && $this->collOrdersRelatedByDeliveryModuleId) { + foreach ($this->collOrdersRelatedByDeliveryModuleId as $obj) { + if ($obj->isNew()) { + $collOrdersRelatedByDeliveryModuleId[] = $obj; + } + } + } + + $this->collOrdersRelatedByDeliveryModuleId = $collOrdersRelatedByDeliveryModuleId; + $this->collOrdersRelatedByDeliveryModuleIdPartial = false; + } + } + + return $this->collOrdersRelatedByDeliveryModuleId; + } + + /** + * Sets a collection of OrderRelatedByDeliveryModuleId objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $ordersRelatedByDeliveryModuleId A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setOrdersRelatedByDeliveryModuleId(Collection $ordersRelatedByDeliveryModuleId, ConnectionInterface $con = null) + { + $ordersRelatedByDeliveryModuleIdToDelete = $this->getOrdersRelatedByDeliveryModuleId(new Criteria(), $con)->diff($ordersRelatedByDeliveryModuleId); + + + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion = $ordersRelatedByDeliveryModuleIdToDelete; + + foreach ($ordersRelatedByDeliveryModuleIdToDelete as $orderRelatedByDeliveryModuleIdRemoved) { + $orderRelatedByDeliveryModuleIdRemoved->setModuleRelatedByDeliveryModuleId(null); + } + + $this->collOrdersRelatedByDeliveryModuleId = null; + foreach ($ordersRelatedByDeliveryModuleId as $orderRelatedByDeliveryModuleId) { + $this->addOrderRelatedByDeliveryModuleId($orderRelatedByDeliveryModuleId); + } + + $this->collOrdersRelatedByDeliveryModuleId = $ordersRelatedByDeliveryModuleId; + $this->collOrdersRelatedByDeliveryModuleIdPartial = false; + + return $this; + } + + /** + * Returns the number of related Order objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Order objects. + * @throws PropelException + */ + public function countOrdersRelatedByDeliveryModuleId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByDeliveryModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryModuleId) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrdersRelatedByDeliveryModuleId()); + } + + $query = ChildOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModuleRelatedByDeliveryModuleId($this) + ->count($con); + } + + return count($this->collOrdersRelatedByDeliveryModuleId); + } + + /** + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. + * + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addOrderRelatedByDeliveryModuleId(ChildOrder $l) + { + if ($this->collOrdersRelatedByDeliveryModuleId === null) { + $this->initOrdersRelatedByDeliveryModuleId(); + $this->collOrdersRelatedByDeliveryModuleIdPartial = true; + } + + if (!in_array($l, $this->collOrdersRelatedByDeliveryModuleId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByDeliveryModuleId($l); + } + + return $this; + } + + /** + * @param OrderRelatedByDeliveryModuleId $orderRelatedByDeliveryModuleId The orderRelatedByDeliveryModuleId object to add. + */ + protected function doAddOrderRelatedByDeliveryModuleId($orderRelatedByDeliveryModuleId) + { + $this->collOrdersRelatedByDeliveryModuleId[]= $orderRelatedByDeliveryModuleId; + $orderRelatedByDeliveryModuleId->setModuleRelatedByDeliveryModuleId($this); + } + + /** + * @param OrderRelatedByDeliveryModuleId $orderRelatedByDeliveryModuleId The orderRelatedByDeliveryModuleId object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeOrderRelatedByDeliveryModuleId($orderRelatedByDeliveryModuleId) + { + if ($this->getOrdersRelatedByDeliveryModuleId()->contains($orderRelatedByDeliveryModuleId)) { + $this->collOrdersRelatedByDeliveryModuleId->remove($this->collOrdersRelatedByDeliveryModuleId->search($orderRelatedByDeliveryModuleId)); + if (null === $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion) { + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion = clone $this->collOrdersRelatedByDeliveryModuleId; + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion->clear(); + } + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion[]= clone $orderRelatedByDeliveryModuleId; + $orderRelatedByDeliveryModuleId->setModuleRelatedByDeliveryModuleId(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + /** + * Clears out the collAreaDeliveryModules collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAreaDeliveryModules() + */ + public function clearAreaDeliveryModules() + { + $this->collAreaDeliveryModules = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collAreaDeliveryModules collection loaded partially. + */ + public function resetPartialAreaDeliveryModules($v = true) + { + $this->collAreaDeliveryModulesPartial = $v; + } + + /** + * Initializes the collAreaDeliveryModules collection. + * + * By default this just sets the collAreaDeliveryModules collection to an empty array (like clearcollAreaDeliveryModules()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAreaDeliveryModules($overrideExisting = true) + { + if (null !== $this->collAreaDeliveryModules && !$overrideExisting) { + return; + } + $this->collAreaDeliveryModules = new ObjectCollection(); + $this->collAreaDeliveryModules->setModel('\Thelia\Model\AreaDeliveryModule'); + } + + /** + * Gets an array of ChildAreaDeliveryModule objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + * @throws PropelException + */ + public function getAreaDeliveryModules($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { + // return empty collection + $this->initAreaDeliveryModules(); + } else { + $collAreaDeliveryModules = ChildAreaDeliveryModuleQuery::create(null, $criteria) + ->filterByModule($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collAreaDeliveryModulesPartial && count($collAreaDeliveryModules)) { + $this->initAreaDeliveryModules(false); + + foreach ($collAreaDeliveryModules as $obj) { + if (false == $this->collAreaDeliveryModules->contains($obj)) { + $this->collAreaDeliveryModules->append($obj); + } + } + + $this->collAreaDeliveryModulesPartial = true; + } + + $collAreaDeliveryModules->getInternalIterator()->rewind(); + + return $collAreaDeliveryModules; + } + + if ($partial && $this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $obj) { + if ($obj->isNew()) { + $collAreaDeliveryModules[] = $obj; + } + } + } + + $this->collAreaDeliveryModules = $collAreaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; + } + } + + return $this->collAreaDeliveryModules; + } + + /** + * Sets a collection of AreaDeliveryModule objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $areaDeliveryModules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setAreaDeliveryModules(Collection $areaDeliveryModules, ConnectionInterface $con = null) + { + $areaDeliveryModulesToDelete = $this->getAreaDeliveryModules(new Criteria(), $con)->diff($areaDeliveryModules); + + + $this->areaDeliveryModulesScheduledForDeletion = $areaDeliveryModulesToDelete; + + foreach ($areaDeliveryModulesToDelete as $areaDeliveryModuleRemoved) { + $areaDeliveryModuleRemoved->setModule(null); + } + + $this->collAreaDeliveryModules = null; + foreach ($areaDeliveryModules as $areaDeliveryModule) { + $this->addAreaDeliveryModule($areaDeliveryModule); + } + + $this->collAreaDeliveryModules = $areaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; + + return $this; + } + + /** + * Returns the number of related AreaDeliveryModule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related AreaDeliveryModule objects. + * @throws PropelException + */ + public function countAreaDeliveryModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAreaDeliveryModules()); + } + + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); + } + + return count($this->collAreaDeliveryModules); + } + + /** + * Method called to associate a ChildAreaDeliveryModule object to this object + * through the ChildAreaDeliveryModule foreign key attribute. + * + * @param ChildAreaDeliveryModule $l ChildAreaDeliveryModule + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addAreaDeliveryModule(ChildAreaDeliveryModule $l) + { + if ($this->collAreaDeliveryModules === null) { + $this->initAreaDeliveryModules(); + $this->collAreaDeliveryModulesPartial = true; + } + + if (!in_array($l, $this->collAreaDeliveryModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAreaDeliveryModule($l); + } + + return $this; + } + + /** + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to add. + */ + protected function doAddAreaDeliveryModule($areaDeliveryModule) + { + $this->collAreaDeliveryModules[]= $areaDeliveryModule; + $areaDeliveryModule->setModule($this); + } + + /** + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeAreaDeliveryModule($areaDeliveryModule) + { + if ($this->getAreaDeliveryModules()->contains($areaDeliveryModule)) { + $this->collAreaDeliveryModules->remove($this->collAreaDeliveryModules->search($areaDeliveryModule)); + if (null === $this->areaDeliveryModulesScheduledForDeletion) { + $this->areaDeliveryModulesScheduledForDeletion = clone $this->collAreaDeliveryModules; + $this->areaDeliveryModulesScheduledForDeletion->clear(); + } + $this->areaDeliveryModulesScheduledForDeletion[]= clone $areaDeliveryModule; + $areaDeliveryModule->setModule(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related AreaDeliveryModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + */ + public function getAreaDeliveryModulesJoinArea($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + $query->joinWith('Area', $joinBehavior); + + return $this->getAreaDeliveryModules($query, $con); + } + /** * Clears out the collGroupModules collection * @@ -1698,6 +2855,224 @@ abstract class Module implements ActiveRecordInterface return $this->getGroupModules($query, $con); } + /** + * Clears out the collModuleImages collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addModuleImages() + */ + public function clearModuleImages() + { + $this->collModuleImages = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collModuleImages collection loaded partially. + */ + public function resetPartialModuleImages($v = true) + { + $this->collModuleImagesPartial = $v; + } + + /** + * Initializes the collModuleImages collection. + * + * By default this just sets the collModuleImages collection to an empty array (like clearcollModuleImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initModuleImages($overrideExisting = true) + { + if (null !== $this->collModuleImages && !$overrideExisting) { + return; + } + $this->collModuleImages = new ObjectCollection(); + $this->collModuleImages->setModel('\Thelia\Model\ModuleImage'); + } + + /** + * Gets an array of ChildModuleImage objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildModuleImage[] List of ChildModuleImage objects + * @throws PropelException + */ + public function getModuleImages($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collModuleImagesPartial && !$this->isNew(); + if (null === $this->collModuleImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collModuleImages) { + // return empty collection + $this->initModuleImages(); + } else { + $collModuleImages = ChildModuleImageQuery::create(null, $criteria) + ->filterByModule($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collModuleImagesPartial && count($collModuleImages)) { + $this->initModuleImages(false); + + foreach ($collModuleImages as $obj) { + if (false == $this->collModuleImages->contains($obj)) { + $this->collModuleImages->append($obj); + } + } + + $this->collModuleImagesPartial = true; + } + + $collModuleImages->getInternalIterator()->rewind(); + + return $collModuleImages; + } + + if ($partial && $this->collModuleImages) { + foreach ($this->collModuleImages as $obj) { + if ($obj->isNew()) { + $collModuleImages[] = $obj; + } + } + } + + $this->collModuleImages = $collModuleImages; + $this->collModuleImagesPartial = false; + } + } + + return $this->collModuleImages; + } + + /** + * Sets a collection of ModuleImage objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $moduleImages A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setModuleImages(Collection $moduleImages, ConnectionInterface $con = null) + { + $moduleImagesToDelete = $this->getModuleImages(new Criteria(), $con)->diff($moduleImages); + + + $this->moduleImagesScheduledForDeletion = $moduleImagesToDelete; + + foreach ($moduleImagesToDelete as $moduleImageRemoved) { + $moduleImageRemoved->setModule(null); + } + + $this->collModuleImages = null; + foreach ($moduleImages as $moduleImage) { + $this->addModuleImage($moduleImage); + } + + $this->collModuleImages = $moduleImages; + $this->collModuleImagesPartial = false; + + return $this; + } + + /** + * Returns the number of related ModuleImage objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ModuleImage objects. + * @throws PropelException + */ + public function countModuleImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collModuleImagesPartial && !$this->isNew(); + if (null === $this->collModuleImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collModuleImages) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getModuleImages()); + } + + $query = ChildModuleImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); + } + + return count($this->collModuleImages); + } + + /** + * Method called to associate a ChildModuleImage object to this object + * through the ChildModuleImage foreign key attribute. + * + * @param ChildModuleImage $l ChildModuleImage + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addModuleImage(ChildModuleImage $l) + { + if ($this->collModuleImages === null) { + $this->initModuleImages(); + $this->collModuleImagesPartial = true; + } + + if (!in_array($l, $this->collModuleImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddModuleImage($l); + } + + return $this; + } + + /** + * @param ModuleImage $moduleImage The moduleImage object to add. + */ + protected function doAddModuleImage($moduleImage) + { + $this->collModuleImages[]= $moduleImage; + $moduleImage->setModule($this); + } + + /** + * @param ModuleImage $moduleImage The moduleImage object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeModuleImage($moduleImage) + { + if ($this->getModuleImages()->contains($moduleImage)) { + $this->collModuleImages->remove($this->collModuleImages->search($moduleImage)); + if (null === $this->moduleImagesScheduledForDeletion) { + $this->moduleImagesScheduledForDeletion = clone $this->collModuleImages; + $this->moduleImagesScheduledForDeletion->clear(); + } + $this->moduleImagesScheduledForDeletion[]= clone $moduleImage; + $moduleImage->setModule(null); + } + + return $this; + } + /** * Clears out the collModuleI18ns collection * @@ -1955,11 +3330,31 @@ abstract class Module implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collOrdersRelatedByPaymentModuleId) { + foreach ($this->collOrdersRelatedByPaymentModuleId as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collOrdersRelatedByDeliveryModuleId) { + foreach ($this->collOrdersRelatedByDeliveryModuleId as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collGroupModules) { foreach ($this->collGroupModules as $o) { $o->clearAllReferences($deep); } } + if ($this->collModuleImages) { + foreach ($this->collModuleImages as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collModuleI18ns) { foreach ($this->collModuleI18ns as $o) { $o->clearAllReferences($deep); @@ -1971,10 +3366,26 @@ abstract class Module implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; + if ($this->collOrdersRelatedByPaymentModuleId instanceof Collection) { + $this->collOrdersRelatedByPaymentModuleId->clearIterator(); + } + $this->collOrdersRelatedByPaymentModuleId = null; + if ($this->collOrdersRelatedByDeliveryModuleId instanceof Collection) { + $this->collOrdersRelatedByDeliveryModuleId->clearIterator(); + } + $this->collOrdersRelatedByDeliveryModuleId = null; + if ($this->collAreaDeliveryModules instanceof Collection) { + $this->collAreaDeliveryModules->clearIterator(); + } + $this->collAreaDeliveryModules = null; if ($this->collGroupModules instanceof Collection) { $this->collGroupModules->clearIterator(); } $this->collGroupModules = null; + if ($this->collModuleImages instanceof Collection) { + $this->collModuleImages->clearIterator(); + } + $this->collModuleImages = null; if ($this->collModuleI18ns instanceof Collection) { $this->collModuleI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ModuleImage.php b/core/lib/Thelia/Model/Base/ModuleImage.php new file mode 100644 index 000000000..f488e289c --- /dev/null +++ b/core/lib/Thelia/Model/Base/ModuleImage.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ModuleImage instance. If + * obj is an instance of ModuleImage, delegates to + * equals(ModuleImage). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ModuleImage The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ModuleImage The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [module_id] column value. + * + * @return int + */ + public function getModuleId() + { + + return $this->module_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ModuleImageTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [module_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function setModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->module_id !== $v) { + $this->module_id = $v; + $this->modifiedColumns[] = ModuleImageTableMap::MODULE_ID; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; + } + + + return $this; + } // setModuleId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = ModuleImageTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ModuleImageTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ModuleImageTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ModuleImageTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ModuleImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ModuleImageTableMap::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ModuleImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ModuleImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ModuleImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ModuleImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ModuleImageTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ModuleImage object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) { + $this->aModule = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ModuleImageTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildModuleImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aModule = null; + $this->collModuleImageI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ModuleImage::setDeleted() + * @see ModuleImage::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildModuleImageQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ModuleImageTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ModuleImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ModuleImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ModuleImageTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->moduleImageI18nsScheduledForDeletion !== null) { + if (!$this->moduleImageI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ModuleImageI18nQuery::create() + ->filterByPrimaryKeys($this->moduleImageI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->moduleImageI18nsScheduledForDeletion = null; + } + } + + if ($this->collModuleImageI18ns !== null) { + foreach ($this->collModuleImageI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ModuleImageTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ModuleImageTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ModuleImageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ModuleImageTableMap::MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'MODULE_ID'; + } + if ($this->isColumnModified(ModuleImageTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(ModuleImageTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ModuleImageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ModuleImageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO module_image (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'MODULE_ID': + $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ModuleImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getModuleId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ModuleImage'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ModuleImage'][$this->getPrimaryKey()] = true; + $keys = ModuleImageTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getModuleId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collModuleImageI18ns) { + $result['ModuleImageI18ns'] = $this->collModuleImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ModuleImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setModuleId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ModuleImageTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setModuleId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ModuleImageTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ModuleImageTableMap::ID)) $criteria->add(ModuleImageTableMap::ID, $this->id); + if ($this->isColumnModified(ModuleImageTableMap::MODULE_ID)) $criteria->add(ModuleImageTableMap::MODULE_ID, $this->module_id); + if ($this->isColumnModified(ModuleImageTableMap::FILE)) $criteria->add(ModuleImageTableMap::FILE, $this->file); + if ($this->isColumnModified(ModuleImageTableMap::POSITION)) $criteria->add(ModuleImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(ModuleImageTableMap::CREATED_AT)) $criteria->add(ModuleImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ModuleImageTableMap::UPDATED_AT)) $criteria->add(ModuleImageTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ModuleImageTableMap::DATABASE_NAME); + $criteria->add(ModuleImageTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ModuleImage (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setModuleId($this->getModuleId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getModuleImageI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addModuleImageI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ModuleImage Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setModuleId(NULL); + } else { + $this->setModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addModuleImage($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->module_id !== null)) { + $this->aModule = ChildModuleQuery::create()->findPk($this->module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModule->addModuleImages($this); + */ + } + + return $this->aModule; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('ModuleImageI18n' == $relationName) { + return $this->initModuleImageI18ns(); + } + } + + /** + * Clears out the collModuleImageI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addModuleImageI18ns() + */ + public function clearModuleImageI18ns() + { + $this->collModuleImageI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collModuleImageI18ns collection loaded partially. + */ + public function resetPartialModuleImageI18ns($v = true) + { + $this->collModuleImageI18nsPartial = $v; + } + + /** + * Initializes the collModuleImageI18ns collection. + * + * By default this just sets the collModuleImageI18ns collection to an empty array (like clearcollModuleImageI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initModuleImageI18ns($overrideExisting = true) + { + if (null !== $this->collModuleImageI18ns && !$overrideExisting) { + return; + } + $this->collModuleImageI18ns = new ObjectCollection(); + $this->collModuleImageI18ns->setModel('\Thelia\Model\ModuleImageI18n'); + } + + /** + * Gets an array of ChildModuleImageI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModuleImage is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildModuleImageI18n[] List of ChildModuleImageI18n objects + * @throws PropelException + */ + public function getModuleImageI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collModuleImageI18nsPartial && !$this->isNew(); + if (null === $this->collModuleImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collModuleImageI18ns) { + // return empty collection + $this->initModuleImageI18ns(); + } else { + $collModuleImageI18ns = ChildModuleImageI18nQuery::create(null, $criteria) + ->filterByModuleImage($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collModuleImageI18nsPartial && count($collModuleImageI18ns)) { + $this->initModuleImageI18ns(false); + + foreach ($collModuleImageI18ns as $obj) { + if (false == $this->collModuleImageI18ns->contains($obj)) { + $this->collModuleImageI18ns->append($obj); + } + } + + $this->collModuleImageI18nsPartial = true; + } + + $collModuleImageI18ns->getInternalIterator()->rewind(); + + return $collModuleImageI18ns; + } + + if ($partial && $this->collModuleImageI18ns) { + foreach ($this->collModuleImageI18ns as $obj) { + if ($obj->isNew()) { + $collModuleImageI18ns[] = $obj; + } + } + } + + $this->collModuleImageI18ns = $collModuleImageI18ns; + $this->collModuleImageI18nsPartial = false; + } + } + + return $this->collModuleImageI18ns; + } + + /** + * Sets a collection of ModuleImageI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $moduleImageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModuleImage The current object (for fluent API support) + */ + public function setModuleImageI18ns(Collection $moduleImageI18ns, ConnectionInterface $con = null) + { + $moduleImageI18nsToDelete = $this->getModuleImageI18ns(new Criteria(), $con)->diff($moduleImageI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->moduleImageI18nsScheduledForDeletion = clone $moduleImageI18nsToDelete; + + foreach ($moduleImageI18nsToDelete as $moduleImageI18nRemoved) { + $moduleImageI18nRemoved->setModuleImage(null); + } + + $this->collModuleImageI18ns = null; + foreach ($moduleImageI18ns as $moduleImageI18n) { + $this->addModuleImageI18n($moduleImageI18n); + } + + $this->collModuleImageI18ns = $moduleImageI18ns; + $this->collModuleImageI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related ModuleImageI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ModuleImageI18n objects. + * @throws PropelException + */ + public function countModuleImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collModuleImageI18nsPartial && !$this->isNew(); + if (null === $this->collModuleImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collModuleImageI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getModuleImageI18ns()); + } + + $query = ChildModuleImageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModuleImage($this) + ->count($con); + } + + return count($this->collModuleImageI18ns); + } + + /** + * Method called to associate a ChildModuleImageI18n object to this object + * through the ChildModuleImageI18n foreign key attribute. + * + * @param ChildModuleImageI18n $l ChildModuleImageI18n + * @return \Thelia\Model\ModuleImage The current object (for fluent API support) + */ + public function addModuleImageI18n(ChildModuleImageI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collModuleImageI18ns === null) { + $this->initModuleImageI18ns(); + $this->collModuleImageI18nsPartial = true; + } + + if (!in_array($l, $this->collModuleImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddModuleImageI18n($l); + } + + return $this; + } + + /** + * @param ModuleImageI18n $moduleImageI18n The moduleImageI18n object to add. + */ + protected function doAddModuleImageI18n($moduleImageI18n) + { + $this->collModuleImageI18ns[]= $moduleImageI18n; + $moduleImageI18n->setModuleImage($this); + } + + /** + * @param ModuleImageI18n $moduleImageI18n The moduleImageI18n object to remove. + * @return ChildModuleImage The current object (for fluent API support) + */ + public function removeModuleImageI18n($moduleImageI18n) + { + if ($this->getModuleImageI18ns()->contains($moduleImageI18n)) { + $this->collModuleImageI18ns->remove($this->collModuleImageI18ns->search($moduleImageI18n)); + if (null === $this->moduleImageI18nsScheduledForDeletion) { + $this->moduleImageI18nsScheduledForDeletion = clone $this->collModuleImageI18ns; + $this->moduleImageI18nsScheduledForDeletion->clear(); + } + $this->moduleImageI18nsScheduledForDeletion[]= clone $moduleImageI18n; + $moduleImageI18n->setModuleImage(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->module_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collModuleImageI18ns) { + foreach ($this->collModuleImageI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collModuleImageI18ns instanceof Collection) { + $this->collModuleImageI18ns->clearIterator(); + } + $this->collModuleImageI18ns = null; + $this->aModule = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ModuleImageTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildModuleImage The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ModuleImageTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildModuleImage The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildModuleImageI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collModuleImageI18ns) { + foreach ($this->collModuleImageI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildModuleImageI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildModuleImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addModuleImageI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildModuleImage The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildModuleImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collModuleImageI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collModuleImageI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildModuleImageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ModuleImageI18n.php b/core/lib/Thelia/Model/Base/ModuleImageI18n.php new file mode 100644 index 000000000..2425b4e65 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ModuleImageI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ModuleImageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ModuleImageI18n instance. If + * obj is an instance of ModuleImageI18n, delegates to + * equals(ModuleImageI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ModuleImageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ModuleImageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ModuleImageI18nTableMap::ID; + } + + if ($this->aModuleImage !== null && $this->aModuleImage->getId() !== $v) { + $this->aModuleImage = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ModuleImageI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ModuleImageI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ModuleImageI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ModuleImageI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ModuleImageI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ModuleImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ModuleImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ModuleImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ModuleImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ModuleImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ModuleImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ModuleImageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ModuleImageI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aModuleImage !== null && $this->id !== $this->aModuleImage->getId()) { + $this->aModuleImage = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildModuleImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aModuleImage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ModuleImageI18n::setDeleted() + * @see ModuleImageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildModuleImageI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ModuleImageI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aModuleImage !== null) { + if ($this->aModuleImage->isModified() || $this->aModuleImage->isNew()) { + $affectedRows += $this->aModuleImage->save($con); + } + $this->setModuleImage($this->aModuleImage); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ModuleImageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ModuleImageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ModuleImageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ModuleImageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ModuleImageI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ModuleImageI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO module_image_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ModuleImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ModuleImageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ModuleImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ModuleImageI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aModuleImage) { + $result['ModuleImage'] = $this->aModuleImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ModuleImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ModuleImageI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ModuleImageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ModuleImageI18nTableMap::ID)) $criteria->add(ModuleImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ModuleImageI18nTableMap::LOCALE)) $criteria->add(ModuleImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ModuleImageI18nTableMap::TITLE)) $criteria->add(ModuleImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ModuleImageI18nTableMap::DESCRIPTION)) $criteria->add(ModuleImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ModuleImageI18nTableMap::CHAPO)) $criteria->add(ModuleImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ModuleImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(ModuleImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ModuleImageI18nTableMap::DATABASE_NAME); + $criteria->add(ModuleImageI18nTableMap::ID, $this->id); + $criteria->add(ModuleImageI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ModuleImageI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ModuleImageI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildModuleImage object. + * + * @param ChildModuleImage $v + * @return \Thelia\Model\ModuleImageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleImage(ChildModuleImage $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aModuleImage = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModuleImage object, it will not be re-added. + if ($v !== null) { + $v->addModuleImageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModuleImage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModuleImage The associated ChildModuleImage object. + * @throws PropelException + */ + public function getModuleImage(ConnectionInterface $con = null) + { + if ($this->aModuleImage === null && ($this->id !== null)) { + $this->aModuleImage = ChildModuleImageQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModuleImage->addModuleImageI18ns($this); + */ + } + + return $this->aModuleImage; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aModuleImage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ModuleImageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ModuleImageI18nQuery.php b/core/lib/Thelia/Model/Base/ModuleImageI18nQuery.php new file mode 100644 index 000000000..e5b6813d6 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ModuleImageI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildModuleImageI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ModuleImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildModuleImageI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM module_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildModuleImageI18n(); + $obj->hydrate($row); + ModuleImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildModuleImageI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(ModuleImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ModuleImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ModuleImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ModuleImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByModuleImage() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ModuleImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ModuleImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ModuleImageI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ModuleImageI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ModuleImageI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ModuleImageI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ModuleImageI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ModuleImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\ModuleImage object + * + * @param \Thelia\Model\ModuleImage|ObjectCollection $moduleImage The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function filterByModuleImage($moduleImage, $comparison = null) + { + if ($moduleImage instanceof \Thelia\Model\ModuleImage) { + return $this + ->addUsingAlias(ModuleImageI18nTableMap::ID, $moduleImage->getId(), $comparison); + } elseif ($moduleImage instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ModuleImageI18nTableMap::ID, $moduleImage->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleImage() only accepts arguments of type \Thelia\Model\ModuleImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function joinModuleImage($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ModuleImage'); + } + + return $this; + } + + /** + * Use the ModuleImage relation ModuleImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleImageQuery A secondary query class using the current class as primary query + */ + public function useModuleImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinModuleImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleImage', '\Thelia\Model\ModuleImageQuery'); + } + + /** + * Exclude object from result + * + * @param ChildModuleImageI18n $moduleImageI18n Object to remove from the list of results + * + * @return ChildModuleImageI18nQuery The current query, for fluid interface + */ + public function prune($moduleImageI18n = null) + { + if ($moduleImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(ModuleImageI18nTableMap::ID), $moduleImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ModuleImageI18nTableMap::LOCALE), $moduleImageI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the module_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ModuleImageI18nTableMap::clearInstancePool(); + ModuleImageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildModuleImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildModuleImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ModuleImageI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ModuleImageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ModuleImageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ModuleImageI18nQuery diff --git a/core/lib/Thelia/Model/Base/ModuleImageQuery.php b/core/lib/Thelia/Model/Base/ModuleImageQuery.php new file mode 100644 index 000000000..966e686ad --- /dev/null +++ b/core/lib/Thelia/Model/Base/ModuleImageQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildModuleImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ModuleImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ModuleImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildModuleImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, MODULE_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM module_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildModuleImage(); + $obj->hydrate($row); + ModuleImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildModuleImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ModuleImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ModuleImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ModuleImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ModuleImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ModuleImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the module_id column + * + * Example usage: + * + * $query->filterByModuleId(1234); // WHERE module_id = 1234 + * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34) + * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12 + * + * + * @see filterByModule() + * + * @param mixed $moduleId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByModuleId($moduleId = null, $comparison = null) + { + if (is_array($moduleId)) { + $useMinMax = false; + if (isset($moduleId['min'])) { + $this->addUsingAlias(ModuleImageTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($moduleId['max'])) { + $this->addUsingAlias(ModuleImageTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ModuleImageTableMap::MODULE_ID, $moduleId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ModuleImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ModuleImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ModuleImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ModuleImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ModuleImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ModuleImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ModuleImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ModuleImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ModuleImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ModuleImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByModule($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(ModuleImageTableMap::MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ModuleImageTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Module'); + } + + return $this; + } + + /** + * Use the Module relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ModuleImageI18n object + * + * @param \Thelia\Model\ModuleImageI18n|ObjectCollection $moduleImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function filterByModuleImageI18n($moduleImageI18n, $comparison = null) + { + if ($moduleImageI18n instanceof \Thelia\Model\ModuleImageI18n) { + return $this + ->addUsingAlias(ModuleImageTableMap::ID, $moduleImageI18n->getId(), $comparison); + } elseif ($moduleImageI18n instanceof ObjectCollection) { + return $this + ->useModuleImageI18nQuery() + ->filterByPrimaryKeys($moduleImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByModuleImageI18n() only accepts arguments of type \Thelia\Model\ModuleImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function joinModuleImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ModuleImageI18n'); + } + + return $this; + } + + /** + * Use the ModuleImageI18n relation ModuleImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleImageI18nQuery A secondary query class using the current class as primary query + */ + public function useModuleImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinModuleImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleImageI18n', '\Thelia\Model\ModuleImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildModuleImage $moduleImage Object to remove from the list of results + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function prune($moduleImage = null) + { + if ($moduleImage) { + $this->addUsingAlias(ModuleImageTableMap::ID, $moduleImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the module_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ModuleImageTableMap::clearInstancePool(); + ModuleImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildModuleImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildModuleImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ModuleImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ModuleImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ModuleImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ModuleImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ModuleImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ModuleImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ModuleImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ModuleImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ModuleImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'ModuleImageI18n'; + + return $this + ->joinModuleImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildModuleImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('ModuleImageI18n'); + $this->with['ModuleImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildModuleImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleImageI18n', '\Thelia\Model\ModuleImageI18nQuery'); + } + +} // ModuleImageQuery diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index 6f8d4b551..4031a4f63 100644 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -44,10 +44,26 @@ use Thelia\Model\Map\ModuleTableMap; * @method ChildModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildModuleQuery leftJoinOrderRelatedByPaymentModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * @method ChildModuleQuery rightJoinOrderRelatedByPaymentModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * @method ChildModuleQuery innerJoinOrderRelatedByPaymentModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * + * @method ChildModuleQuery leftJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * @method ChildModuleQuery rightJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * @method ChildModuleQuery innerJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * + * @method ChildModuleQuery leftJoinAreaDeliveryModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildModuleQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildModuleQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation + * * @method ChildModuleQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation * @method ChildModuleQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation * @method ChildModuleQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation * + * @method ChildModuleQuery leftJoinModuleImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleImage relation + * @method ChildModuleQuery rightJoinModuleImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleImage relation + * @method ChildModuleQuery innerJoinModuleImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleImage relation + * * @method ChildModuleQuery leftJoinModuleI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleI18n relation * @method ChildModuleQuery rightJoinModuleI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleI18n relation * @method ChildModuleQuery innerJoinModuleI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleI18n relation @@ -557,6 +573,225 @@ abstract class ModuleQuery extends ModelCriteria return $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByOrderRelatedByPaymentModuleId($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $order->getPaymentModuleId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + return $this + ->useOrderRelatedByPaymentModuleIdQuery() + ->filterByPrimaryKeys($order->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderRelatedByPaymentModuleId() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinOrderRelatedByPaymentModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderRelatedByPaymentModuleId'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderRelatedByPaymentModuleId'); + } + + return $this; + } + + /** + * Use the OrderRelatedByPaymentModuleId relation Order object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderRelatedByPaymentModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderRelatedByPaymentModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByPaymentModuleId', '\Thelia\Model\OrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByOrderRelatedByDeliveryModuleId($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $order->getDeliveryModuleId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + return $this + ->useOrderRelatedByDeliveryModuleIdQuery() + ->filterByPrimaryKeys($order->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderRelatedByDeliveryModuleId() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinOrderRelatedByDeliveryModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderRelatedByDeliveryModuleId'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderRelatedByDeliveryModuleId'); + } + + return $this; + } + + /** + * Use the OrderRelatedByDeliveryModuleId relation Order object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderRelatedByDeliveryModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderRelatedByDeliveryModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByDeliveryModuleId', '\Thelia\Model\OrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\AreaDeliveryModule object + * + * @param \Thelia\Model\AreaDeliveryModule|ObjectCollection $areaDeliveryModule the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByAreaDeliveryModule($areaDeliveryModule, $comparison = null) + { + if ($areaDeliveryModule instanceof \Thelia\Model\AreaDeliveryModule) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $areaDeliveryModule->getDeliveryModuleId(), $comparison); + } elseif ($areaDeliveryModule instanceof ObjectCollection) { + return $this + ->useAreaDeliveryModuleQuery() + ->filterByPrimaryKeys($areaDeliveryModule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAreaDeliveryModule() only accepts arguments of type \Thelia\Model\AreaDeliveryModule or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the AreaDeliveryModule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinAreaDeliveryModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AreaDeliveryModule'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'AreaDeliveryModule'); + } + + return $this; + } + + /** + * Use the AreaDeliveryModule relation AreaDeliveryModule object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AreaDeliveryModuleQuery A secondary query class using the current class as primary query + */ + public function useAreaDeliveryModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAreaDeliveryModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AreaDeliveryModule', '\Thelia\Model\AreaDeliveryModuleQuery'); + } + /** * Filter the query by a related \Thelia\Model\GroupModule object * @@ -630,6 +865,79 @@ abstract class ModuleQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); } + /** + * Filter the query by a related \Thelia\Model\ModuleImage object + * + * @param \Thelia\Model\ModuleImage|ObjectCollection $moduleImage the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByModuleImage($moduleImage, $comparison = null) + { + if ($moduleImage instanceof \Thelia\Model\ModuleImage) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $moduleImage->getModuleId(), $comparison); + } elseif ($moduleImage instanceof ObjectCollection) { + return $this + ->useModuleImageQuery() + ->filterByPrimaryKeys($moduleImage->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByModuleImage() only accepts arguments of type \Thelia\Model\ModuleImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinModuleImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ModuleImage'); + } + + return $this; + } + + /** + * Use the ModuleImage relation ModuleImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleImageQuery A secondary query class using the current class as primary query + */ + public function useModuleImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleImage', '\Thelia\Model\ModuleImageQuery'); + } + /** * Filter the query by a related \Thelia\Model\ModuleI18n object * diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index 6932ec6c4..a2cd3f829 100644 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -23,6 +23,10 @@ use Thelia\Model\Currency as ChildCurrency; use Thelia\Model\CurrencyQuery as ChildCurrencyQuery; use Thelia\Model\Customer as ChildCustomer; use Thelia\Model\CustomerQuery as ChildCustomerQuery; +use Thelia\Model\Lang as ChildLang; +use Thelia\Model\LangQuery as ChildLangQuery; +use Thelia\Model\Module as ChildModule; +use Thelia\Model\ModuleQuery as ChildModuleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderAddress as ChildOrderAddress; use Thelia\Model\OrderAddressQuery as ChildOrderAddressQuery; @@ -86,16 +90,16 @@ abstract class Order implements ActiveRecordInterface protected $customer_id; /** - * The value for the address_invoice field. + * The value for the invoice_order_address_id field. * @var int */ - protected $address_invoice; + protected $invoice_order_address_id; /** - * The value for the address_delivery field. + * The value for the delivery_order_address_id field. * @var int */ - protected $address_delivery; + protected $delivery_order_address_id; /** * The value for the invoice_date field. @@ -116,22 +120,22 @@ abstract class Order implements ActiveRecordInterface protected $currency_rate; /** - * The value for the transaction field. + * The value for the transaction_ref field. * @var string */ - protected $transaction; + protected $transaction_ref; /** - * The value for the delivery_num field. + * The value for the delivery_ref field. * @var string */ - protected $delivery_num; + protected $delivery_ref; /** - * The value for the invoice field. + * The value for the invoice_ref field. * @var string */ - protected $invoice; + protected $invoice_ref; /** * The value for the postage field. @@ -140,16 +144,16 @@ abstract class Order implements ActiveRecordInterface protected $postage; /** - * The value for the payment field. - * @var string + * The value for the payment_module_id field. + * @var int */ - protected $payment; + protected $payment_module_id; /** - * The value for the carrier field. - * @var string + * The value for the delivery_module_id field. + * @var int */ - protected $carrier; + protected $delivery_module_id; /** * The value for the status_id field. @@ -158,10 +162,10 @@ abstract class Order implements ActiveRecordInterface protected $status_id; /** - * The value for the lang field. - * @var string + * The value for the lang_id field. + * @var int */ - protected $lang; + protected $lang_id; /** * The value for the created_at field. @@ -188,18 +192,33 @@ abstract class Order implements ActiveRecordInterface /** * @var OrderAddress */ - protected $aOrderAddressRelatedByAddressInvoice; + protected $aOrderAddressRelatedByInvoiceOrderAddressId; /** * @var OrderAddress */ - protected $aOrderAddressRelatedByAddressDelivery; + protected $aOrderAddressRelatedByDeliveryOrderAddressId; /** * @var OrderStatus */ protected $aOrderStatus; + /** + * @var Module + */ + protected $aModuleRelatedByPaymentModuleId; + + /** + * @var Module + */ + protected $aModuleRelatedByDeliveryModuleId; + + /** + * @var Lang + */ + protected $aLang; + /** * @var ObjectCollection|ChildOrderProduct[] Collection to store aggregation of ChildOrderProduct objects. */ @@ -520,25 +539,25 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [address_invoice] column value. + * Get the [invoice_order_address_id] column value. * * @return int */ - public function getAddressInvoice() + public function getInvoiceOrderAddressId() { - return $this->address_invoice; + return $this->invoice_order_address_id; } /** - * Get the [address_delivery] column value. + * Get the [delivery_order_address_id] column value. * * @return int */ - public function getAddressDelivery() + public function getDeliveryOrderAddressId() { - return $this->address_delivery; + return $this->delivery_order_address_id; } /** @@ -584,36 +603,36 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [transaction] column value. - * + * Get the [transaction_ref] column value. + * transaction reference - usually use to identify a transaction with banking modules * @return string */ - public function getTransaction() + public function getTransactionRef() { - return $this->transaction; + return $this->transaction_ref; } /** - * Get the [delivery_num] column value. - * + * Get the [delivery_ref] column value. + * delivery reference - usually use to identify a delivery progress on a distant delivery tracker website * @return string */ - public function getDeliveryNum() + public function getDeliveryRef() { - return $this->delivery_num; + return $this->delivery_ref; } /** - * Get the [invoice] column value. - * + * Get the [invoice_ref] column value. + * the invoice reference * @return string */ - public function getInvoice() + public function getInvoiceRef() { - return $this->invoice; + return $this->invoice_ref; } /** @@ -628,25 +647,25 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [payment] column value. + * Get the [payment_module_id] column value. * - * @return string + * @return int */ - public function getPayment() + public function getPaymentModuleId() { - return $this->payment; + return $this->payment_module_id; } /** - * Get the [carrier] column value. + * Get the [delivery_module_id] column value. * - * @return string + * @return int */ - public function getCarrier() + public function getDeliveryModuleId() { - return $this->carrier; + return $this->delivery_module_id; } /** @@ -661,14 +680,14 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [lang] column value. + * Get the [lang_id] column value. * - * @return string + * @return int */ - public function getLang() + public function getLangId() { - return $this->lang; + return $this->lang_id; } /** @@ -779,54 +798,54 @@ abstract class Order implements ActiveRecordInterface } // setCustomerId() /** - * Set the value of [address_invoice] column. + * Set the value of [invoice_order_address_id] column. * * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setAddressInvoice($v) + public function setInvoiceOrderAddressId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->address_invoice !== $v) { - $this->address_invoice = $v; - $this->modifiedColumns[] = OrderTableMap::ADDRESS_INVOICE; + if ($this->invoice_order_address_id !== $v) { + $this->invoice_order_address_id = $v; + $this->modifiedColumns[] = OrderTableMap::INVOICE_ORDER_ADDRESS_ID; } - if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) { - $this->aOrderAddressRelatedByAddressInvoice = null; + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId !== null && $this->aOrderAddressRelatedByInvoiceOrderAddressId->getId() !== $v) { + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; } return $this; - } // setAddressInvoice() + } // setInvoiceOrderAddressId() /** - * Set the value of [address_delivery] column. + * Set the value of [delivery_order_address_id] column. * * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setAddressDelivery($v) + public function setDeliveryOrderAddressId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->address_delivery !== $v) { - $this->address_delivery = $v; - $this->modifiedColumns[] = OrderTableMap::ADDRESS_DELIVERY; + if ($this->delivery_order_address_id !== $v) { + $this->delivery_order_address_id = $v; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_ORDER_ADDRESS_ID; } - if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) { - $this->aOrderAddressRelatedByAddressDelivery = null; + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId !== null && $this->aOrderAddressRelatedByDeliveryOrderAddressId->getId() !== $v) { + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; } return $this; - } // setAddressDelivery() + } // setDeliveryOrderAddressId() /** * Sets the value of [invoice_date] column to a normalized version of the date/time value specified. @@ -896,67 +915,67 @@ abstract class Order implements ActiveRecordInterface } // setCurrencyRate() /** - * Set the value of [transaction] column. - * + * Set the value of [transaction_ref] column. + * transaction reference - usually use to identify a transaction with banking modules * @param string $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setTransaction($v) + public function setTransactionRef($v) { if ($v !== null) { $v = (string) $v; } - if ($this->transaction !== $v) { - $this->transaction = $v; - $this->modifiedColumns[] = OrderTableMap::TRANSACTION; + if ($this->transaction_ref !== $v) { + $this->transaction_ref = $v; + $this->modifiedColumns[] = OrderTableMap::TRANSACTION_REF; } return $this; - } // setTransaction() + } // setTransactionRef() /** - * Set the value of [delivery_num] column. - * + * Set the value of [delivery_ref] column. + * delivery reference - usually use to identify a delivery progress on a distant delivery tracker website * @param string $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setDeliveryNum($v) + public function setDeliveryRef($v) { if ($v !== null) { $v = (string) $v; } - if ($this->delivery_num !== $v) { - $this->delivery_num = $v; - $this->modifiedColumns[] = OrderTableMap::DELIVERY_NUM; + if ($this->delivery_ref !== $v) { + $this->delivery_ref = $v; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_REF; } return $this; - } // setDeliveryNum() + } // setDeliveryRef() /** - * Set the value of [invoice] column. - * + * Set the value of [invoice_ref] column. + * the invoice reference * @param string $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setInvoice($v) + public function setInvoiceRef($v) { if ($v !== null) { $v = (string) $v; } - if ($this->invoice !== $v) { - $this->invoice = $v; - $this->modifiedColumns[] = OrderTableMap::INVOICE; + if ($this->invoice_ref !== $v) { + $this->invoice_ref = $v; + $this->modifiedColumns[] = OrderTableMap::INVOICE_REF; } return $this; - } // setInvoice() + } // setInvoiceRef() /** * Set the value of [postage] column. @@ -980,46 +999,54 @@ abstract class Order implements ActiveRecordInterface } // setPostage() /** - * Set the value of [payment] column. + * Set the value of [payment_module_id] column. * - * @param string $v new value + * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setPayment($v) + public function setPaymentModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->payment !== $v) { - $this->payment = $v; - $this->modifiedColumns[] = OrderTableMap::PAYMENT; + if ($this->payment_module_id !== $v) { + $this->payment_module_id = $v; + $this->modifiedColumns[] = OrderTableMap::PAYMENT_MODULE_ID; + } + + if ($this->aModuleRelatedByPaymentModuleId !== null && $this->aModuleRelatedByPaymentModuleId->getId() !== $v) { + $this->aModuleRelatedByPaymentModuleId = null; } return $this; - } // setPayment() + } // setPaymentModuleId() /** - * Set the value of [carrier] column. + * Set the value of [delivery_module_id] column. * - * @param string $v new value + * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setCarrier($v) + public function setDeliveryModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->carrier !== $v) { - $this->carrier = $v; - $this->modifiedColumns[] = OrderTableMap::CARRIER; + if ($this->delivery_module_id !== $v) { + $this->delivery_module_id = $v; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_MODULE_ID; + } + + if ($this->aModuleRelatedByDeliveryModuleId !== null && $this->aModuleRelatedByDeliveryModuleId->getId() !== $v) { + $this->aModuleRelatedByDeliveryModuleId = null; } return $this; - } // setCarrier() + } // setDeliveryModuleId() /** * Set the value of [status_id] column. @@ -1047,25 +1074,29 @@ abstract class Order implements ActiveRecordInterface } // setStatusId() /** - * Set the value of [lang] column. + * Set the value of [lang_id] column. * - * @param string $v new value + * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setLang($v) + public function setLangId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->lang !== $v) { - $this->lang = $v; - $this->modifiedColumns[] = OrderTableMap::LANG; + if ($this->lang_id !== $v) { + $this->lang_id = $v; + $this->modifiedColumns[] = OrderTableMap::LANG_ID; + } + + if ($this->aLang !== null && $this->aLang->getId() !== $v) { + $this->aLang = null; } return $this; - } // setLang() + } // setLangId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -1155,11 +1186,11 @@ abstract class Order implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)]; $this->customer_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderTableMap::translateFieldName('AddressInvoice', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address_invoice = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderTableMap::translateFieldName('InvoiceOrderAddressId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->invoice_order_address_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderTableMap::translateFieldName('AddressDelivery', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address_delivery = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderTableMap::translateFieldName('DeliveryOrderAddressId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_order_address_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderTableMap::translateFieldName('InvoiceDate', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00') { @@ -1173,29 +1204,29 @@ abstract class Order implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderTableMap::translateFieldName('CurrencyRate', TableMap::TYPE_PHPNAME, $indexType)]; $this->currency_rate = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderTableMap::translateFieldName('Transaction', TableMap::TYPE_PHPNAME, $indexType)]; - $this->transaction = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderTableMap::translateFieldName('TransactionRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->transaction_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderTableMap::translateFieldName('DeliveryNum', TableMap::TYPE_PHPNAME, $indexType)]; - $this->delivery_num = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderTableMap::translateFieldName('DeliveryRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('Invoice', TableMap::TYPE_PHPNAME, $indexType)]; - $this->invoice = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('InvoiceRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->invoice_ref = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; $this->postage = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('Payment', TableMap::TYPE_PHPNAME, $indexType)]; - $this->payment = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->payment_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('Carrier', TableMap::TYPE_PHPNAME, $indexType)]; - $this->carrier = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_module_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)]; $this->status_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; - $this->lang = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('LangId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lang_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -1241,18 +1272,27 @@ abstract class Order implements ActiveRecordInterface if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { $this->aCustomer = null; } - if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->address_invoice !== $this->aOrderAddressRelatedByAddressInvoice->getId()) { - $this->aOrderAddressRelatedByAddressInvoice = null; + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId !== null && $this->invoice_order_address_id !== $this->aOrderAddressRelatedByInvoiceOrderAddressId->getId()) { + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; } - if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->address_delivery !== $this->aOrderAddressRelatedByAddressDelivery->getId()) { - $this->aOrderAddressRelatedByAddressDelivery = null; + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId !== null && $this->delivery_order_address_id !== $this->aOrderAddressRelatedByDeliveryOrderAddressId->getId()) { + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; } if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) { $this->aCurrency = null; } + if ($this->aModuleRelatedByPaymentModuleId !== null && $this->payment_module_id !== $this->aModuleRelatedByPaymentModuleId->getId()) { + $this->aModuleRelatedByPaymentModuleId = null; + } + if ($this->aModuleRelatedByDeliveryModuleId !== null && $this->delivery_module_id !== $this->aModuleRelatedByDeliveryModuleId->getId()) { + $this->aModuleRelatedByDeliveryModuleId = null; + } if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) { $this->aOrderStatus = null; } + if ($this->aLang !== null && $this->lang_id !== $this->aLang->getId()) { + $this->aLang = null; + } } // ensureConsistency /** @@ -1294,9 +1334,12 @@ abstract class Order implements ActiveRecordInterface $this->aCurrency = null; $this->aCustomer = null; - $this->aOrderAddressRelatedByAddressInvoice = null; - $this->aOrderAddressRelatedByAddressDelivery = null; + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; $this->aOrderStatus = null; + $this->aModuleRelatedByPaymentModuleId = null; + $this->aModuleRelatedByDeliveryModuleId = null; + $this->aLang = null; $this->collOrderProducts = null; $this->collCouponOrders = null; @@ -1442,18 +1485,18 @@ abstract class Order implements ActiveRecordInterface $this->setCustomer($this->aCustomer); } - if ($this->aOrderAddressRelatedByAddressInvoice !== null) { - if ($this->aOrderAddressRelatedByAddressInvoice->isModified() || $this->aOrderAddressRelatedByAddressInvoice->isNew()) { - $affectedRows += $this->aOrderAddressRelatedByAddressInvoice->save($con); + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId !== null) { + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId->isModified() || $this->aOrderAddressRelatedByInvoiceOrderAddressId->isNew()) { + $affectedRows += $this->aOrderAddressRelatedByInvoiceOrderAddressId->save($con); } - $this->setOrderAddressRelatedByAddressInvoice($this->aOrderAddressRelatedByAddressInvoice); + $this->setOrderAddressRelatedByInvoiceOrderAddressId($this->aOrderAddressRelatedByInvoiceOrderAddressId); } - if ($this->aOrderAddressRelatedByAddressDelivery !== null) { - if ($this->aOrderAddressRelatedByAddressDelivery->isModified() || $this->aOrderAddressRelatedByAddressDelivery->isNew()) { - $affectedRows += $this->aOrderAddressRelatedByAddressDelivery->save($con); + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId !== null) { + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId->isModified() || $this->aOrderAddressRelatedByDeliveryOrderAddressId->isNew()) { + $affectedRows += $this->aOrderAddressRelatedByDeliveryOrderAddressId->save($con); } - $this->setOrderAddressRelatedByAddressDelivery($this->aOrderAddressRelatedByAddressDelivery); + $this->setOrderAddressRelatedByDeliveryOrderAddressId($this->aOrderAddressRelatedByDeliveryOrderAddressId); } if ($this->aOrderStatus !== null) { @@ -1463,6 +1506,27 @@ abstract class Order implements ActiveRecordInterface $this->setOrderStatus($this->aOrderStatus); } + if ($this->aModuleRelatedByPaymentModuleId !== null) { + if ($this->aModuleRelatedByPaymentModuleId->isModified() || $this->aModuleRelatedByPaymentModuleId->isNew()) { + $affectedRows += $this->aModuleRelatedByPaymentModuleId->save($con); + } + $this->setModuleRelatedByPaymentModuleId($this->aModuleRelatedByPaymentModuleId); + } + + if ($this->aModuleRelatedByDeliveryModuleId !== null) { + if ($this->aModuleRelatedByDeliveryModuleId->isModified() || $this->aModuleRelatedByDeliveryModuleId->isNew()) { + $affectedRows += $this->aModuleRelatedByDeliveryModuleId->save($con); + } + $this->setModuleRelatedByDeliveryModuleId($this->aModuleRelatedByDeliveryModuleId); + } + + if ($this->aLang !== null) { + if ($this->aLang->isModified() || $this->aLang->isNew()) { + $affectedRows += $this->aLang->save($con); + } + $this->setLang($this->aLang); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1543,11 +1607,11 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; } - if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS_INVOICE'; + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID'; } - if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS_DELIVERY'; + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID'; } if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) { $modifiedColumns[':p' . $index++] = 'INVOICE_DATE'; @@ -1558,29 +1622,29 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; } - if ($this->isColumnModified(OrderTableMap::TRANSACTION)) { - $modifiedColumns[':p' . $index++] = 'TRANSACTION'; + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF'; } - if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) { - $modifiedColumns[':p' . $index++] = 'DELIVERY_NUM'; + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_REF'; } - if ($this->isColumnModified(OrderTableMap::INVOICE)) { - $modifiedColumns[':p' . $index++] = 'INVOICE'; + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_REF'; } if ($this->isColumnModified(OrderTableMap::POSTAGE)) { $modifiedColumns[':p' . $index++] = 'POSTAGE'; } - if ($this->isColumnModified(OrderTableMap::PAYMENT)) { - $modifiedColumns[':p' . $index++] = 'PAYMENT'; + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; } - if ($this->isColumnModified(OrderTableMap::CARRIER)) { - $modifiedColumns[':p' . $index++] = 'CARRIER'; + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; } if ($this->isColumnModified(OrderTableMap::STATUS_ID)) { $modifiedColumns[':p' . $index++] = 'STATUS_ID'; } - if ($this->isColumnModified(OrderTableMap::LANG)) { - $modifiedColumns[':p' . $index++] = 'LANG'; + if ($this->isColumnModified(OrderTableMap::LANG_ID)) { + $modifiedColumns[':p' . $index++] = 'LANG_ID'; } if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1608,11 +1672,11 @@ abstract class Order implements ActiveRecordInterface case 'CUSTOMER_ID': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case 'ADDRESS_INVOICE': - $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT); + case 'INVOICE_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT); break; - case 'ADDRESS_DELIVERY': - $stmt->bindValue($identifier, $this->address_delivery, PDO::PARAM_INT); + case 'DELIVERY_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT); break; case 'INVOICE_DATE': $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1623,29 +1687,29 @@ abstract class Order implements ActiveRecordInterface case 'CURRENCY_RATE': $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); break; - case 'TRANSACTION': - $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR); + case 'TRANSACTION_REF': + $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR); break; - case 'DELIVERY_NUM': - $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR); + case 'DELIVERY_REF': + $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR); break; - case 'INVOICE': - $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR); + case 'INVOICE_REF': + $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR); break; case 'POSTAGE': $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); break; - case 'PAYMENT': - $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR); + case 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); break; - case 'CARRIER': - $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR); + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); break; case 'STATUS_ID': $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); break; - case 'LANG': - $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); + case 'LANG_ID': + $stmt->bindValue($identifier, $this->lang_id, PDO::PARAM_INT); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1725,10 +1789,10 @@ abstract class Order implements ActiveRecordInterface return $this->getCustomerId(); break; case 3: - return $this->getAddressInvoice(); + return $this->getInvoiceOrderAddressId(); break; case 4: - return $this->getAddressDelivery(); + return $this->getDeliveryOrderAddressId(); break; case 5: return $this->getInvoiceDate(); @@ -1740,28 +1804,28 @@ abstract class Order implements ActiveRecordInterface return $this->getCurrencyRate(); break; case 8: - return $this->getTransaction(); + return $this->getTransactionRef(); break; case 9: - return $this->getDeliveryNum(); + return $this->getDeliveryRef(); break; case 10: - return $this->getInvoice(); + return $this->getInvoiceRef(); break; case 11: return $this->getPostage(); break; case 12: - return $this->getPayment(); + return $this->getPaymentModuleId(); break; case 13: - return $this->getCarrier(); + return $this->getDeliveryModuleId(); break; case 14: return $this->getStatusId(); break; case 15: - return $this->getLang(); + return $this->getLangId(); break; case 16: return $this->getCreatedAt(); @@ -1801,19 +1865,19 @@ abstract class Order implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getRef(), $keys[2] => $this->getCustomerId(), - $keys[3] => $this->getAddressInvoice(), - $keys[4] => $this->getAddressDelivery(), + $keys[3] => $this->getInvoiceOrderAddressId(), + $keys[4] => $this->getDeliveryOrderAddressId(), $keys[5] => $this->getInvoiceDate(), $keys[6] => $this->getCurrencyId(), $keys[7] => $this->getCurrencyRate(), - $keys[8] => $this->getTransaction(), - $keys[9] => $this->getDeliveryNum(), - $keys[10] => $this->getInvoice(), + $keys[8] => $this->getTransactionRef(), + $keys[9] => $this->getDeliveryRef(), + $keys[10] => $this->getInvoiceRef(), $keys[11] => $this->getPostage(), - $keys[12] => $this->getPayment(), - $keys[13] => $this->getCarrier(), + $keys[12] => $this->getPaymentModuleId(), + $keys[13] => $this->getDeliveryModuleId(), $keys[14] => $this->getStatusId(), - $keys[15] => $this->getLang(), + $keys[15] => $this->getLangId(), $keys[16] => $this->getCreatedAt(), $keys[17] => $this->getUpdatedAt(), ); @@ -1830,15 +1894,24 @@ abstract class Order implements ActiveRecordInterface if (null !== $this->aCustomer) { $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aOrderAddressRelatedByAddressInvoice) { - $result['OrderAddressRelatedByAddressInvoice'] = $this->aOrderAddressRelatedByAddressInvoice->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aOrderAddressRelatedByInvoiceOrderAddressId) { + $result['OrderAddressRelatedByInvoiceOrderAddressId'] = $this->aOrderAddressRelatedByInvoiceOrderAddressId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aOrderAddressRelatedByAddressDelivery) { - $result['OrderAddressRelatedByAddressDelivery'] = $this->aOrderAddressRelatedByAddressDelivery->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aOrderAddressRelatedByDeliveryOrderAddressId) { + $result['OrderAddressRelatedByDeliveryOrderAddressId'] = $this->aOrderAddressRelatedByDeliveryOrderAddressId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aOrderStatus) { $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aModuleRelatedByPaymentModuleId) { + $result['ModuleRelatedByPaymentModuleId'] = $this->aModuleRelatedByPaymentModuleId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aModuleRelatedByDeliveryModuleId) { + $result['ModuleRelatedByDeliveryModuleId'] = $this->aModuleRelatedByDeliveryModuleId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aLang) { + $result['Lang'] = $this->aLang->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } if (null !== $this->collOrderProducts) { $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1889,10 +1962,10 @@ abstract class Order implements ActiveRecordInterface $this->setCustomerId($value); break; case 3: - $this->setAddressInvoice($value); + $this->setInvoiceOrderAddressId($value); break; case 4: - $this->setAddressDelivery($value); + $this->setDeliveryOrderAddressId($value); break; case 5: $this->setInvoiceDate($value); @@ -1904,28 +1977,28 @@ abstract class Order implements ActiveRecordInterface $this->setCurrencyRate($value); break; case 8: - $this->setTransaction($value); + $this->setTransactionRef($value); break; case 9: - $this->setDeliveryNum($value); + $this->setDeliveryRef($value); break; case 10: - $this->setInvoice($value); + $this->setInvoiceRef($value); break; case 11: $this->setPostage($value); break; case 12: - $this->setPayment($value); + $this->setPaymentModuleId($value); break; case 13: - $this->setCarrier($value); + $this->setDeliveryModuleId($value); break; case 14: $this->setStatusId($value); break; case 15: - $this->setLang($value); + $this->setLangId($value); break; case 16: $this->setCreatedAt($value); @@ -1960,19 +2033,19 @@ abstract class Order implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAddressInvoice($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAddressDelivery($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setInvoiceOrderAddressId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDeliveryOrderAddressId($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setInvoiceDate($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setCurrencyId($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setCurrencyRate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTransaction($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDeliveryNum($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setInvoice($arr[$keys[10]]); + if (array_key_exists($keys[8], $arr)) $this->setTransactionRef($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDeliveryRef($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setInvoiceRef($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setPostage($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setPayment($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setCarrier($arr[$keys[13]]); + if (array_key_exists($keys[12], $arr)) $this->setPaymentModuleId($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setDeliveryModuleId($arr[$keys[13]]); if (array_key_exists($keys[14], $arr)) $this->setStatusId($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setLang($arr[$keys[15]]); + if (array_key_exists($keys[15], $arr)) $this->setLangId($arr[$keys[15]]); if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); } @@ -1989,19 +2062,19 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::ID)) $criteria->add(OrderTableMap::ID, $this->id); if ($this->isColumnModified(OrderTableMap::REF)) $criteria->add(OrderTableMap::REF, $this->ref); if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) $criteria->add(OrderTableMap::CUSTOMER_ID, $this->customer_id); - if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) $criteria->add(OrderTableMap::ADDRESS_INVOICE, $this->address_invoice); - if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) $criteria->add(OrderTableMap::ADDRESS_DELIVERY, $this->address_delivery); + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) $criteria->add(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $this->invoice_order_address_id); + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) $criteria->add(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $this->delivery_order_address_id); if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) $criteria->add(OrderTableMap::INVOICE_DATE, $this->invoice_date); if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) $criteria->add(OrderTableMap::CURRENCY_ID, $this->currency_id); if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) $criteria->add(OrderTableMap::CURRENCY_RATE, $this->currency_rate); - if ($this->isColumnModified(OrderTableMap::TRANSACTION)) $criteria->add(OrderTableMap::TRANSACTION, $this->transaction); - if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) $criteria->add(OrderTableMap::DELIVERY_NUM, $this->delivery_num); - if ($this->isColumnModified(OrderTableMap::INVOICE)) $criteria->add(OrderTableMap::INVOICE, $this->invoice); + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) $criteria->add(OrderTableMap::TRANSACTION_REF, $this->transaction_ref); + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) $criteria->add(OrderTableMap::DELIVERY_REF, $this->delivery_ref); + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) $criteria->add(OrderTableMap::INVOICE_REF, $this->invoice_ref); if ($this->isColumnModified(OrderTableMap::POSTAGE)) $criteria->add(OrderTableMap::POSTAGE, $this->postage); - if ($this->isColumnModified(OrderTableMap::PAYMENT)) $criteria->add(OrderTableMap::PAYMENT, $this->payment); - if ($this->isColumnModified(OrderTableMap::CARRIER)) $criteria->add(OrderTableMap::CARRIER, $this->carrier); + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) $criteria->add(OrderTableMap::PAYMENT_MODULE_ID, $this->payment_module_id); + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) $criteria->add(OrderTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); if ($this->isColumnModified(OrderTableMap::STATUS_ID)) $criteria->add(OrderTableMap::STATUS_ID, $this->status_id); - if ($this->isColumnModified(OrderTableMap::LANG)) $criteria->add(OrderTableMap::LANG, $this->lang); + if ($this->isColumnModified(OrderTableMap::LANG_ID)) $criteria->add(OrderTableMap::LANG_ID, $this->lang_id); if ($this->isColumnModified(OrderTableMap::CREATED_AT)) $criteria->add(OrderTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) $criteria->add(OrderTableMap::UPDATED_AT, $this->updated_at); @@ -2069,19 +2142,19 @@ abstract class Order implements ActiveRecordInterface { $copyObj->setRef($this->getRef()); $copyObj->setCustomerId($this->getCustomerId()); - $copyObj->setAddressInvoice($this->getAddressInvoice()); - $copyObj->setAddressDelivery($this->getAddressDelivery()); + $copyObj->setInvoiceOrderAddressId($this->getInvoiceOrderAddressId()); + $copyObj->setDeliveryOrderAddressId($this->getDeliveryOrderAddressId()); $copyObj->setInvoiceDate($this->getInvoiceDate()); $copyObj->setCurrencyId($this->getCurrencyId()); $copyObj->setCurrencyRate($this->getCurrencyRate()); - $copyObj->setTransaction($this->getTransaction()); - $copyObj->setDeliveryNum($this->getDeliveryNum()); - $copyObj->setInvoice($this->getInvoice()); + $copyObj->setTransactionRef($this->getTransactionRef()); + $copyObj->setDeliveryRef($this->getDeliveryRef()); + $copyObj->setInvoiceRef($this->getInvoiceRef()); $copyObj->setPostage($this->getPostage()); - $copyObj->setPayment($this->getPayment()); - $copyObj->setCarrier($this->getCarrier()); + $copyObj->setPaymentModuleId($this->getPaymentModuleId()); + $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); $copyObj->setStatusId($this->getStatusId()); - $copyObj->setLang($this->getLang()); + $copyObj->setLangId($this->getLangId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2241,20 +2314,20 @@ abstract class Order implements ActiveRecordInterface * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderAddressRelatedByAddressInvoice(ChildOrderAddress $v = null) + public function setOrderAddressRelatedByInvoiceOrderAddressId(ChildOrderAddress $v = null) { if ($v === null) { - $this->setAddressInvoice(NULL); + $this->setInvoiceOrderAddressId(NULL); } else { - $this->setAddressInvoice($v->getId()); + $this->setInvoiceOrderAddressId($v->getId()); } - $this->aOrderAddressRelatedByAddressInvoice = $v; + $this->aOrderAddressRelatedByInvoiceOrderAddressId = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildOrderAddress object, it will not be re-added. if ($v !== null) { - $v->addOrderRelatedByAddressInvoice($this); + $v->addOrderRelatedByInvoiceOrderAddressId($this); } @@ -2269,20 +2342,20 @@ abstract class Order implements ActiveRecordInterface * @return ChildOrderAddress The associated ChildOrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressInvoice(ConnectionInterface $con = null) + public function getOrderAddressRelatedByInvoiceOrderAddressId(ConnectionInterface $con = null) { - if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null)) { - $this->aOrderAddressRelatedByAddressInvoice = ChildOrderAddressQuery::create()->findPk($this->address_invoice, $con); + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId === null && ($this->invoice_order_address_id !== null)) { + $this->aOrderAddressRelatedByInvoiceOrderAddressId = ChildOrderAddressQuery::create()->findPk($this->invoice_order_address_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aOrderAddressRelatedByAddressInvoice->addOrdersRelatedByAddressInvoice($this); + $this->aOrderAddressRelatedByInvoiceOrderAddressId->addOrdersRelatedByInvoiceOrderAddressId($this); */ } - return $this->aOrderAddressRelatedByAddressInvoice; + return $this->aOrderAddressRelatedByInvoiceOrderAddressId; } /** @@ -2292,20 +2365,20 @@ abstract class Order implements ActiveRecordInterface * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderAddressRelatedByAddressDelivery(ChildOrderAddress $v = null) + public function setOrderAddressRelatedByDeliveryOrderAddressId(ChildOrderAddress $v = null) { if ($v === null) { - $this->setAddressDelivery(NULL); + $this->setDeliveryOrderAddressId(NULL); } else { - $this->setAddressDelivery($v->getId()); + $this->setDeliveryOrderAddressId($v->getId()); } - $this->aOrderAddressRelatedByAddressDelivery = $v; + $this->aOrderAddressRelatedByDeliveryOrderAddressId = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildOrderAddress object, it will not be re-added. if ($v !== null) { - $v->addOrderRelatedByAddressDelivery($this); + $v->addOrderRelatedByDeliveryOrderAddressId($this); } @@ -2320,20 +2393,20 @@ abstract class Order implements ActiveRecordInterface * @return ChildOrderAddress The associated ChildOrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressDelivery(ConnectionInterface $con = null) + public function getOrderAddressRelatedByDeliveryOrderAddressId(ConnectionInterface $con = null) { - if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null)) { - $this->aOrderAddressRelatedByAddressDelivery = ChildOrderAddressQuery::create()->findPk($this->address_delivery, $con); + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId === null && ($this->delivery_order_address_id !== null)) { + $this->aOrderAddressRelatedByDeliveryOrderAddressId = ChildOrderAddressQuery::create()->findPk($this->delivery_order_address_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aOrderAddressRelatedByAddressDelivery->addOrdersRelatedByAddressDelivery($this); + $this->aOrderAddressRelatedByDeliveryOrderAddressId->addOrdersRelatedByDeliveryOrderAddressId($this); */ } - return $this->aOrderAddressRelatedByAddressDelivery; + return $this->aOrderAddressRelatedByDeliveryOrderAddressId; } /** @@ -2387,6 +2460,159 @@ abstract class Order implements ActiveRecordInterface return $this->aOrderStatus; } + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\Order The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleRelatedByPaymentModuleId(ChildModule $v = null) + { + if ($v === null) { + $this->setPaymentModuleId(NULL); + } else { + $this->setPaymentModuleId($v->getId()); + } + + $this->aModuleRelatedByPaymentModuleId = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addOrderRelatedByPaymentModuleId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModuleRelatedByPaymentModuleId(ConnectionInterface $con = null) + { + if ($this->aModuleRelatedByPaymentModuleId === null && ($this->payment_module_id !== null)) { + $this->aModuleRelatedByPaymentModuleId = ChildModuleQuery::create()->findPk($this->payment_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModuleRelatedByPaymentModuleId->addOrdersRelatedByPaymentModuleId($this); + */ + } + + return $this->aModuleRelatedByPaymentModuleId; + } + + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\Order The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleRelatedByDeliveryModuleId(ChildModule $v = null) + { + if ($v === null) { + $this->setDeliveryModuleId(NULL); + } else { + $this->setDeliveryModuleId($v->getId()); + } + + $this->aModuleRelatedByDeliveryModuleId = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addOrderRelatedByDeliveryModuleId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModuleRelatedByDeliveryModuleId(ConnectionInterface $con = null) + { + if ($this->aModuleRelatedByDeliveryModuleId === null && ($this->delivery_module_id !== null)) { + $this->aModuleRelatedByDeliveryModuleId = ChildModuleQuery::create()->findPk($this->delivery_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModuleRelatedByDeliveryModuleId->addOrdersRelatedByDeliveryModuleId($this); + */ + } + + return $this->aModuleRelatedByDeliveryModuleId; + } + + /** + * Declares an association between this object and a ChildLang object. + * + * @param ChildLang $v + * @return \Thelia\Model\Order The current object (for fluent API support) + * @throws PropelException + */ + public function setLang(ChildLang $v = null) + { + if ($v === null) { + $this->setLangId(NULL); + } else { + $this->setLangId($v->getId()); + } + + $this->aLang = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildLang object, it will not be re-added. + if ($v !== null) { + $v->addOrder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildLang object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildLang The associated ChildLang object. + * @throws PropelException + */ + public function getLang(ConnectionInterface $con = null) + { + if ($this->aLang === null && ($this->lang_id !== null)) { + $this->aLang = ChildLangQuery::create()->findPk($this->lang_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aLang->addOrders($this); + */ + } + + return $this->aLang; + } + /** * Initializes a collection based on the name of a relation. @@ -2850,19 +3076,19 @@ abstract class Order implements ActiveRecordInterface $this->id = null; $this->ref = null; $this->customer_id = null; - $this->address_invoice = null; - $this->address_delivery = null; + $this->invoice_order_address_id = null; + $this->delivery_order_address_id = null; $this->invoice_date = null; $this->currency_id = null; $this->currency_rate = null; - $this->transaction = null; - $this->delivery_num = null; - $this->invoice = null; + $this->transaction_ref = null; + $this->delivery_ref = null; + $this->invoice_ref = null; $this->postage = null; - $this->payment = null; - $this->carrier = null; + $this->payment_module_id = null; + $this->delivery_module_id = null; $this->status_id = null; - $this->lang = null; + $this->lang_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -2906,9 +3132,12 @@ abstract class Order implements ActiveRecordInterface $this->collCouponOrders = null; $this->aCurrency = null; $this->aCustomer = null; - $this->aOrderAddressRelatedByAddressInvoice = null; - $this->aOrderAddressRelatedByAddressDelivery = null; + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; $this->aOrderStatus = null; + $this->aModuleRelatedByPaymentModuleId = null; + $this->aModuleRelatedByDeliveryModuleId = null; + $this->aLang = null; } /** diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php index d0220d4e0..c5502321a 100644 --- a/core/lib/Thelia/Model/Base/OrderAddress.php +++ b/core/lib/Thelia/Model/Base/OrderAddress.php @@ -144,14 +144,14 @@ abstract class OrderAddress implements ActiveRecordInterface /** * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. */ - protected $collOrdersRelatedByAddressInvoice; - protected $collOrdersRelatedByAddressInvoicePartial; + protected $collOrdersRelatedByInvoiceOrderAddressId; + protected $collOrdersRelatedByInvoiceOrderAddressIdPartial; /** * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. */ - protected $collOrdersRelatedByAddressDelivery; - protected $collOrdersRelatedByAddressDeliveryPartial; + protected $collOrdersRelatedByDeliveryOrderAddressId; + protected $collOrdersRelatedByDeliveryOrderAddressIdPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -165,13 +165,13 @@ abstract class OrderAddress implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $ordersRelatedByAddressInvoiceScheduledForDeletion = null; + protected $ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $ordersRelatedByAddressDeliveryScheduledForDeletion = null; + protected $ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\OrderAddress object. @@ -1046,9 +1046,9 @@ abstract class OrderAddress implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collOrdersRelatedByAddressInvoice = null; + $this->collOrdersRelatedByInvoiceOrderAddressId = null; - $this->collOrdersRelatedByAddressDelivery = null; + $this->collOrdersRelatedByDeliveryOrderAddressId = null; } // if (deep) } @@ -1183,36 +1183,34 @@ abstract class OrderAddress implements ActiveRecordInterface $this->resetModified(); } - if ($this->ordersRelatedByAddressInvoiceScheduledForDeletion !== null) { - if (!$this->ordersRelatedByAddressInvoiceScheduledForDeletion->isEmpty()) { - foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoice) { - // need to save related object because we set the relation to null - $orderRelatedByAddressInvoice->save($con); - } - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = null; + if ($this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = null; } } - if ($this->collOrdersRelatedByAddressInvoice !== null) { - foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { + if ($this->collOrdersRelatedByInvoiceOrderAddressId !== null) { + foreach ($this->collOrdersRelatedByInvoiceOrderAddressId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } - if ($this->ordersRelatedByAddressDeliveryScheduledForDeletion !== null) { - if (!$this->ordersRelatedByAddressDeliveryScheduledForDeletion->isEmpty()) { - foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDelivery) { - // need to save related object because we set the relation to null - $orderRelatedByAddressDelivery->save($con); - } - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = null; + if ($this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = null; } } - if ($this->collOrdersRelatedByAddressDelivery !== null) { - foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { + if ($this->collOrdersRelatedByDeliveryOrderAddressId !== null) { + foreach ($this->collOrdersRelatedByDeliveryOrderAddressId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1495,11 +1493,11 @@ abstract class OrderAddress implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collOrdersRelatedByAddressInvoice) { - $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrdersRelatedByInvoiceOrderAddressId) { + $result['OrdersRelatedByInvoiceOrderAddressId'] = $this->collOrdersRelatedByInvoiceOrderAddressId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collOrdersRelatedByAddressDelivery) { - $result['OrdersRelatedByAddressDelivery'] = $this->collOrdersRelatedByAddressDelivery->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrdersRelatedByDeliveryOrderAddressId) { + $result['OrdersRelatedByDeliveryOrderAddressId'] = $this->collOrdersRelatedByDeliveryOrderAddressId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1722,15 +1720,15 @@ abstract class OrderAddress implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getOrdersRelatedByAddressInvoice() as $relObj) { + foreach ($this->getOrdersRelatedByInvoiceOrderAddressId() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderRelatedByAddressInvoice($relObj->copy($deepCopy)); + $copyObj->addOrderRelatedByInvoiceOrderAddressId($relObj->copy($deepCopy)); } } - foreach ($this->getOrdersRelatedByAddressDelivery() as $relObj) { + foreach ($this->getOrdersRelatedByDeliveryOrderAddressId() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderRelatedByAddressDelivery($relObj->copy($deepCopy)); + $copyObj->addOrderRelatedByDeliveryOrderAddressId($relObj->copy($deepCopy)); } } @@ -1775,40 +1773,40 @@ abstract class OrderAddress implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('OrderRelatedByAddressInvoice' == $relationName) { - return $this->initOrdersRelatedByAddressInvoice(); + if ('OrderRelatedByInvoiceOrderAddressId' == $relationName) { + return $this->initOrdersRelatedByInvoiceOrderAddressId(); } - if ('OrderRelatedByAddressDelivery' == $relationName) { - return $this->initOrdersRelatedByAddressDelivery(); + if ('OrderRelatedByDeliveryOrderAddressId' == $relationName) { + return $this->initOrdersRelatedByDeliveryOrderAddressId(); } } /** - * Clears out the collOrdersRelatedByAddressInvoice collection + * Clears out the collOrdersRelatedByInvoiceOrderAddressId collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addOrdersRelatedByAddressInvoice() + * @see addOrdersRelatedByInvoiceOrderAddressId() */ - public function clearOrdersRelatedByAddressInvoice() + public function clearOrdersRelatedByInvoiceOrderAddressId() { - $this->collOrdersRelatedByAddressInvoice = null; // important to set this to NULL since that means it is uninitialized + $this->collOrdersRelatedByInvoiceOrderAddressId = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrdersRelatedByAddressInvoice collection loaded partially. + * Reset is the collOrdersRelatedByInvoiceOrderAddressId collection loaded partially. */ - public function resetPartialOrdersRelatedByAddressInvoice($v = true) + public function resetPartialOrdersRelatedByInvoiceOrderAddressId($v = true) { - $this->collOrdersRelatedByAddressInvoicePartial = $v; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = $v; } /** - * Initializes the collOrdersRelatedByAddressInvoice collection. + * Initializes the collOrdersRelatedByInvoiceOrderAddressId collection. * - * By default this just sets the collOrdersRelatedByAddressInvoice collection to an empty array (like clearcollOrdersRelatedByAddressInvoice()); + * By default this just sets the collOrdersRelatedByInvoiceOrderAddressId collection to an empty array (like clearcollOrdersRelatedByInvoiceOrderAddressId()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1817,13 +1815,13 @@ abstract class OrderAddress implements ActiveRecordInterface * * @return void */ - public function initOrdersRelatedByAddressInvoice($overrideExisting = true) + public function initOrdersRelatedByInvoiceOrderAddressId($overrideExisting = true) { - if (null !== $this->collOrdersRelatedByAddressInvoice && !$overrideExisting) { + if (null !== $this->collOrdersRelatedByInvoiceOrderAddressId && !$overrideExisting) { return; } - $this->collOrdersRelatedByAddressInvoice = new ObjectCollection(); - $this->collOrdersRelatedByAddressInvoice->setModel('\Thelia\Model\Order'); + $this->collOrdersRelatedByInvoiceOrderAddressId = new ObjectCollection(); + $this->collOrdersRelatedByInvoiceOrderAddressId->setModel('\Thelia\Model\Order'); } /** @@ -1840,80 +1838,80 @@ abstract class OrderAddress implements ActiveRecordInterface * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrdersRelatedByAddressInvoice($criteria = null, ConnectionInterface $con = null) + public function getOrdersRelatedByInvoiceOrderAddressId($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { + $partial = $this->collOrdersRelatedByInvoiceOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByInvoiceOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByInvoiceOrderAddressId) { // return empty collection - $this->initOrdersRelatedByAddressInvoice(); + $this->initOrdersRelatedByInvoiceOrderAddressId(); } else { - $collOrdersRelatedByAddressInvoice = ChildOrderQuery::create(null, $criteria) - ->filterByOrderAddressRelatedByAddressInvoice($this) + $collOrdersRelatedByInvoiceOrderAddressId = ChildOrderQuery::create(null, $criteria) + ->filterByOrderAddressRelatedByInvoiceOrderAddressId($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrdersRelatedByAddressInvoicePartial && count($collOrdersRelatedByAddressInvoice)) { - $this->initOrdersRelatedByAddressInvoice(false); + if (false !== $this->collOrdersRelatedByInvoiceOrderAddressIdPartial && count($collOrdersRelatedByInvoiceOrderAddressId)) { + $this->initOrdersRelatedByInvoiceOrderAddressId(false); - foreach ($collOrdersRelatedByAddressInvoice as $obj) { - if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) { - $this->collOrdersRelatedByAddressInvoice->append($obj); + foreach ($collOrdersRelatedByInvoiceOrderAddressId as $obj) { + if (false == $this->collOrdersRelatedByInvoiceOrderAddressId->contains($obj)) { + $this->collOrdersRelatedByInvoiceOrderAddressId->append($obj); } } - $this->collOrdersRelatedByAddressInvoicePartial = true; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = true; } - $collOrdersRelatedByAddressInvoice->getInternalIterator()->rewind(); + $collOrdersRelatedByInvoiceOrderAddressId->getInternalIterator()->rewind(); - return $collOrdersRelatedByAddressInvoice; + return $collOrdersRelatedByInvoiceOrderAddressId; } - if ($partial && $this->collOrdersRelatedByAddressInvoice) { - foreach ($this->collOrdersRelatedByAddressInvoice as $obj) { + if ($partial && $this->collOrdersRelatedByInvoiceOrderAddressId) { + foreach ($this->collOrdersRelatedByInvoiceOrderAddressId as $obj) { if ($obj->isNew()) { - $collOrdersRelatedByAddressInvoice[] = $obj; + $collOrdersRelatedByInvoiceOrderAddressId[] = $obj; } } } - $this->collOrdersRelatedByAddressInvoice = $collOrdersRelatedByAddressInvoice; - $this->collOrdersRelatedByAddressInvoicePartial = false; + $this->collOrdersRelatedByInvoiceOrderAddressId = $collOrdersRelatedByInvoiceOrderAddressId; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = false; } } - return $this->collOrdersRelatedByAddressInvoice; + return $this->collOrdersRelatedByInvoiceOrderAddressId; } /** - * Sets a collection of OrderRelatedByAddressInvoice objects related by a one-to-many relationship + * Sets a collection of OrderRelatedByInvoiceOrderAddressId objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $ordersRelatedByAddressInvoice A Propel collection. + * @param Collection $ordersRelatedByInvoiceOrderAddressId A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderAddress The current object (for fluent API support) */ - public function setOrdersRelatedByAddressInvoice(Collection $ordersRelatedByAddressInvoice, ConnectionInterface $con = null) + public function setOrdersRelatedByInvoiceOrderAddressId(Collection $ordersRelatedByInvoiceOrderAddressId, ConnectionInterface $con = null) { - $ordersRelatedByAddressInvoiceToDelete = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice); + $ordersRelatedByInvoiceOrderAddressIdToDelete = $this->getOrdersRelatedByInvoiceOrderAddressId(new Criteria(), $con)->diff($ordersRelatedByInvoiceOrderAddressId); - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = $ordersRelatedByAddressInvoiceToDelete; + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = $ordersRelatedByInvoiceOrderAddressIdToDelete; - foreach ($ordersRelatedByAddressInvoiceToDelete as $orderRelatedByAddressInvoiceRemoved) { - $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null); + foreach ($ordersRelatedByInvoiceOrderAddressIdToDelete as $orderRelatedByInvoiceOrderAddressIdRemoved) { + $orderRelatedByInvoiceOrderAddressIdRemoved->setOrderAddressRelatedByInvoiceOrderAddressId(null); } - $this->collOrdersRelatedByAddressInvoice = null; - foreach ($ordersRelatedByAddressInvoice as $orderRelatedByAddressInvoice) { - $this->addOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice); + $this->collOrdersRelatedByInvoiceOrderAddressId = null; + foreach ($ordersRelatedByInvoiceOrderAddressId as $orderRelatedByInvoiceOrderAddressId) { + $this->addOrderRelatedByInvoiceOrderAddressId($orderRelatedByInvoiceOrderAddressId); } - $this->collOrdersRelatedByAddressInvoice = $ordersRelatedByAddressInvoice; - $this->collOrdersRelatedByAddressInvoicePartial = false; + $this->collOrdersRelatedByInvoiceOrderAddressId = $ordersRelatedByInvoiceOrderAddressId; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = false; return $this; } @@ -1927,16 +1925,16 @@ abstract class OrderAddress implements ActiveRecordInterface * @return int Count of related Order objects. * @throws PropelException */ - public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrdersRelatedByInvoiceOrderAddressId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { + $partial = $this->collOrdersRelatedByInvoiceOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByInvoiceOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByInvoiceOrderAddressId) { return 0; } if ($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressInvoice()); + return count($this->getOrdersRelatedByInvoiceOrderAddressId()); } $query = ChildOrderQuery::create(null, $criteria); @@ -1945,11 +1943,11 @@ abstract class OrderAddress implements ActiveRecordInterface } return $query - ->filterByOrderAddressRelatedByAddressInvoice($this) + ->filterByOrderAddressRelatedByInvoiceOrderAddressId($this) ->count($con); } - return count($this->collOrdersRelatedByAddressInvoice); + return count($this->collOrdersRelatedByInvoiceOrderAddressId); } /** @@ -1959,43 +1957,43 @@ abstract class OrderAddress implements ActiveRecordInterface * @param ChildOrder $l ChildOrder * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ - public function addOrderRelatedByAddressInvoice(ChildOrder $l) + public function addOrderRelatedByInvoiceOrderAddressId(ChildOrder $l) { - if ($this->collOrdersRelatedByAddressInvoice === null) { - $this->initOrdersRelatedByAddressInvoice(); - $this->collOrdersRelatedByAddressInvoicePartial = true; + if ($this->collOrdersRelatedByInvoiceOrderAddressId === null) { + $this->initOrdersRelatedByInvoiceOrderAddressId(); + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = true; } - if (!in_array($l, $this->collOrdersRelatedByAddressInvoice->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderRelatedByAddressInvoice($l); + if (!in_array($l, $this->collOrdersRelatedByInvoiceOrderAddressId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByInvoiceOrderAddressId($l); } return $this; } /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add. + * @param OrderRelatedByInvoiceOrderAddressId $orderRelatedByInvoiceOrderAddressId The orderRelatedByInvoiceOrderAddressId object to add. */ - protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) + protected function doAddOrderRelatedByInvoiceOrderAddressId($orderRelatedByInvoiceOrderAddressId) { - $this->collOrdersRelatedByAddressInvoice[]= $orderRelatedByAddressInvoice; - $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice($this); + $this->collOrdersRelatedByInvoiceOrderAddressId[]= $orderRelatedByInvoiceOrderAddressId; + $orderRelatedByInvoiceOrderAddressId->setOrderAddressRelatedByInvoiceOrderAddressId($this); } /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove. + * @param OrderRelatedByInvoiceOrderAddressId $orderRelatedByInvoiceOrderAddressId The orderRelatedByInvoiceOrderAddressId object to remove. * @return ChildOrderAddress The current object (for fluent API support) */ - public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) + public function removeOrderRelatedByInvoiceOrderAddressId($orderRelatedByInvoiceOrderAddressId) { - if ($this->getOrdersRelatedByAddressInvoice()->contains($orderRelatedByAddressInvoice)) { - $this->collOrdersRelatedByAddressInvoice->remove($this->collOrdersRelatedByAddressInvoice->search($orderRelatedByAddressInvoice)); - if (null === $this->ordersRelatedByAddressInvoiceScheduledForDeletion) { - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = clone $this->collOrdersRelatedByAddressInvoice; - $this->ordersRelatedByAddressInvoiceScheduledForDeletion->clear(); + if ($this->getOrdersRelatedByInvoiceOrderAddressId()->contains($orderRelatedByInvoiceOrderAddressId)) { + $this->collOrdersRelatedByInvoiceOrderAddressId->remove($this->collOrdersRelatedByInvoiceOrderAddressId->search($orderRelatedByInvoiceOrderAddressId)); + if (null === $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion) { + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = clone $this->collOrdersRelatedByInvoiceOrderAddressId; + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion->clear(); } - $this->ordersRelatedByAddressInvoiceScheduledForDeletion[]= $orderRelatedByAddressInvoice; - $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice(null); + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion[]= clone $orderRelatedByInvoiceOrderAddressId; + $orderRelatedByInvoiceOrderAddressId->setOrderAddressRelatedByInvoiceOrderAddressId(null); } return $this; @@ -2007,7 +2005,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2018,12 +2016,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByInvoiceOrderAddressIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Currency', $joinBehavior); - return $this->getOrdersRelatedByAddressInvoice($query, $con); + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); } @@ -2032,7 +2030,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2043,12 +2041,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByInvoiceOrderAddressIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Customer', $joinBehavior); - return $this->getOrdersRelatedByAddressInvoice($query, $con); + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); } @@ -2057,7 +2055,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2068,40 +2066,115 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByInvoiceOrderAddressIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('OrderStatus', $joinBehavior); - return $this->getOrdersRelatedByAddressInvoice($query, $con); + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByInvoiceOrderAddressIdJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByInvoiceOrderAddressIdJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByInvoiceOrderAddressIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); } /** - * Clears out the collOrdersRelatedByAddressDelivery collection + * Clears out the collOrdersRelatedByDeliveryOrderAddressId collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addOrdersRelatedByAddressDelivery() + * @see addOrdersRelatedByDeliveryOrderAddressId() */ - public function clearOrdersRelatedByAddressDelivery() + public function clearOrdersRelatedByDeliveryOrderAddressId() { - $this->collOrdersRelatedByAddressDelivery = null; // important to set this to NULL since that means it is uninitialized + $this->collOrdersRelatedByDeliveryOrderAddressId = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrdersRelatedByAddressDelivery collection loaded partially. + * Reset is the collOrdersRelatedByDeliveryOrderAddressId collection loaded partially. */ - public function resetPartialOrdersRelatedByAddressDelivery($v = true) + public function resetPartialOrdersRelatedByDeliveryOrderAddressId($v = true) { - $this->collOrdersRelatedByAddressDeliveryPartial = $v; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = $v; } /** - * Initializes the collOrdersRelatedByAddressDelivery collection. + * Initializes the collOrdersRelatedByDeliveryOrderAddressId collection. * - * By default this just sets the collOrdersRelatedByAddressDelivery collection to an empty array (like clearcollOrdersRelatedByAddressDelivery()); + * By default this just sets the collOrdersRelatedByDeliveryOrderAddressId collection to an empty array (like clearcollOrdersRelatedByDeliveryOrderAddressId()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -2110,13 +2183,13 @@ abstract class OrderAddress implements ActiveRecordInterface * * @return void */ - public function initOrdersRelatedByAddressDelivery($overrideExisting = true) + public function initOrdersRelatedByDeliveryOrderAddressId($overrideExisting = true) { - if (null !== $this->collOrdersRelatedByAddressDelivery && !$overrideExisting) { + if (null !== $this->collOrdersRelatedByDeliveryOrderAddressId && !$overrideExisting) { return; } - $this->collOrdersRelatedByAddressDelivery = new ObjectCollection(); - $this->collOrdersRelatedByAddressDelivery->setModel('\Thelia\Model\Order'); + $this->collOrdersRelatedByDeliveryOrderAddressId = new ObjectCollection(); + $this->collOrdersRelatedByDeliveryOrderAddressId->setModel('\Thelia\Model\Order'); } /** @@ -2133,80 +2206,80 @@ abstract class OrderAddress implements ActiveRecordInterface * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrdersRelatedByAddressDelivery($criteria = null, ConnectionInterface $con = null) + public function getOrdersRelatedByDeliveryOrderAddressId($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { + $partial = $this->collOrdersRelatedByDeliveryOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryOrderAddressId) { // return empty collection - $this->initOrdersRelatedByAddressDelivery(); + $this->initOrdersRelatedByDeliveryOrderAddressId(); } else { - $collOrdersRelatedByAddressDelivery = ChildOrderQuery::create(null, $criteria) - ->filterByOrderAddressRelatedByAddressDelivery($this) + $collOrdersRelatedByDeliveryOrderAddressId = ChildOrderQuery::create(null, $criteria) + ->filterByOrderAddressRelatedByDeliveryOrderAddressId($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrdersRelatedByAddressDeliveryPartial && count($collOrdersRelatedByAddressDelivery)) { - $this->initOrdersRelatedByAddressDelivery(false); + if (false !== $this->collOrdersRelatedByDeliveryOrderAddressIdPartial && count($collOrdersRelatedByDeliveryOrderAddressId)) { + $this->initOrdersRelatedByDeliveryOrderAddressId(false); - foreach ($collOrdersRelatedByAddressDelivery as $obj) { - if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) { - $this->collOrdersRelatedByAddressDelivery->append($obj); + foreach ($collOrdersRelatedByDeliveryOrderAddressId as $obj) { + if (false == $this->collOrdersRelatedByDeliveryOrderAddressId->contains($obj)) { + $this->collOrdersRelatedByDeliveryOrderAddressId->append($obj); } } - $this->collOrdersRelatedByAddressDeliveryPartial = true; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = true; } - $collOrdersRelatedByAddressDelivery->getInternalIterator()->rewind(); + $collOrdersRelatedByDeliveryOrderAddressId->getInternalIterator()->rewind(); - return $collOrdersRelatedByAddressDelivery; + return $collOrdersRelatedByDeliveryOrderAddressId; } - if ($partial && $this->collOrdersRelatedByAddressDelivery) { - foreach ($this->collOrdersRelatedByAddressDelivery as $obj) { + if ($partial && $this->collOrdersRelatedByDeliveryOrderAddressId) { + foreach ($this->collOrdersRelatedByDeliveryOrderAddressId as $obj) { if ($obj->isNew()) { - $collOrdersRelatedByAddressDelivery[] = $obj; + $collOrdersRelatedByDeliveryOrderAddressId[] = $obj; } } } - $this->collOrdersRelatedByAddressDelivery = $collOrdersRelatedByAddressDelivery; - $this->collOrdersRelatedByAddressDeliveryPartial = false; + $this->collOrdersRelatedByDeliveryOrderAddressId = $collOrdersRelatedByDeliveryOrderAddressId; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = false; } } - return $this->collOrdersRelatedByAddressDelivery; + return $this->collOrdersRelatedByDeliveryOrderAddressId; } /** - * Sets a collection of OrderRelatedByAddressDelivery objects related by a one-to-many relationship + * Sets a collection of OrderRelatedByDeliveryOrderAddressId objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $ordersRelatedByAddressDelivery A Propel collection. + * @param Collection $ordersRelatedByDeliveryOrderAddressId A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderAddress The current object (for fluent API support) */ - public function setOrdersRelatedByAddressDelivery(Collection $ordersRelatedByAddressDelivery, ConnectionInterface $con = null) + public function setOrdersRelatedByDeliveryOrderAddressId(Collection $ordersRelatedByDeliveryOrderAddressId, ConnectionInterface $con = null) { - $ordersRelatedByAddressDeliveryToDelete = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery); + $ordersRelatedByDeliveryOrderAddressIdToDelete = $this->getOrdersRelatedByDeliveryOrderAddressId(new Criteria(), $con)->diff($ordersRelatedByDeliveryOrderAddressId); - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = $ordersRelatedByAddressDeliveryToDelete; + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = $ordersRelatedByDeliveryOrderAddressIdToDelete; - foreach ($ordersRelatedByAddressDeliveryToDelete as $orderRelatedByAddressDeliveryRemoved) { - $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null); + foreach ($ordersRelatedByDeliveryOrderAddressIdToDelete as $orderRelatedByDeliveryOrderAddressIdRemoved) { + $orderRelatedByDeliveryOrderAddressIdRemoved->setOrderAddressRelatedByDeliveryOrderAddressId(null); } - $this->collOrdersRelatedByAddressDelivery = null; - foreach ($ordersRelatedByAddressDelivery as $orderRelatedByAddressDelivery) { - $this->addOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery); + $this->collOrdersRelatedByDeliveryOrderAddressId = null; + foreach ($ordersRelatedByDeliveryOrderAddressId as $orderRelatedByDeliveryOrderAddressId) { + $this->addOrderRelatedByDeliveryOrderAddressId($orderRelatedByDeliveryOrderAddressId); } - $this->collOrdersRelatedByAddressDelivery = $ordersRelatedByAddressDelivery; - $this->collOrdersRelatedByAddressDeliveryPartial = false; + $this->collOrdersRelatedByDeliveryOrderAddressId = $ordersRelatedByDeliveryOrderAddressId; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = false; return $this; } @@ -2220,16 +2293,16 @@ abstract class OrderAddress implements ActiveRecordInterface * @return int Count of related Order objects. * @throws PropelException */ - public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrdersRelatedByDeliveryOrderAddressId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { + $partial = $this->collOrdersRelatedByDeliveryOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryOrderAddressId) { return 0; } if ($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressDelivery()); + return count($this->getOrdersRelatedByDeliveryOrderAddressId()); } $query = ChildOrderQuery::create(null, $criteria); @@ -2238,11 +2311,11 @@ abstract class OrderAddress implements ActiveRecordInterface } return $query - ->filterByOrderAddressRelatedByAddressDelivery($this) + ->filterByOrderAddressRelatedByDeliveryOrderAddressId($this) ->count($con); } - return count($this->collOrdersRelatedByAddressDelivery); + return count($this->collOrdersRelatedByDeliveryOrderAddressId); } /** @@ -2252,43 +2325,43 @@ abstract class OrderAddress implements ActiveRecordInterface * @param ChildOrder $l ChildOrder * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ - public function addOrderRelatedByAddressDelivery(ChildOrder $l) + public function addOrderRelatedByDeliveryOrderAddressId(ChildOrder $l) { - if ($this->collOrdersRelatedByAddressDelivery === null) { - $this->initOrdersRelatedByAddressDelivery(); - $this->collOrdersRelatedByAddressDeliveryPartial = true; + if ($this->collOrdersRelatedByDeliveryOrderAddressId === null) { + $this->initOrdersRelatedByDeliveryOrderAddressId(); + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = true; } - if (!in_array($l, $this->collOrdersRelatedByAddressDelivery->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderRelatedByAddressDelivery($l); + if (!in_array($l, $this->collOrdersRelatedByDeliveryOrderAddressId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByDeliveryOrderAddressId($l); } return $this; } /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add. + * @param OrderRelatedByDeliveryOrderAddressId $orderRelatedByDeliveryOrderAddressId The orderRelatedByDeliveryOrderAddressId object to add. */ - protected function doAddOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) + protected function doAddOrderRelatedByDeliveryOrderAddressId($orderRelatedByDeliveryOrderAddressId) { - $this->collOrdersRelatedByAddressDelivery[]= $orderRelatedByAddressDelivery; - $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery($this); + $this->collOrdersRelatedByDeliveryOrderAddressId[]= $orderRelatedByDeliveryOrderAddressId; + $orderRelatedByDeliveryOrderAddressId->setOrderAddressRelatedByDeliveryOrderAddressId($this); } /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove. + * @param OrderRelatedByDeliveryOrderAddressId $orderRelatedByDeliveryOrderAddressId The orderRelatedByDeliveryOrderAddressId object to remove. * @return ChildOrderAddress The current object (for fluent API support) */ - public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) + public function removeOrderRelatedByDeliveryOrderAddressId($orderRelatedByDeliveryOrderAddressId) { - if ($this->getOrdersRelatedByAddressDelivery()->contains($orderRelatedByAddressDelivery)) { - $this->collOrdersRelatedByAddressDelivery->remove($this->collOrdersRelatedByAddressDelivery->search($orderRelatedByAddressDelivery)); - if (null === $this->ordersRelatedByAddressDeliveryScheduledForDeletion) { - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = clone $this->collOrdersRelatedByAddressDelivery; - $this->ordersRelatedByAddressDeliveryScheduledForDeletion->clear(); + if ($this->getOrdersRelatedByDeliveryOrderAddressId()->contains($orderRelatedByDeliveryOrderAddressId)) { + $this->collOrdersRelatedByDeliveryOrderAddressId->remove($this->collOrdersRelatedByDeliveryOrderAddressId->search($orderRelatedByDeliveryOrderAddressId)); + if (null === $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion) { + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = clone $this->collOrdersRelatedByDeliveryOrderAddressId; + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion->clear(); } - $this->ordersRelatedByAddressDeliveryScheduledForDeletion[]= $orderRelatedByAddressDelivery; - $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery(null); + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion[]= clone $orderRelatedByDeliveryOrderAddressId; + $orderRelatedByDeliveryOrderAddressId->setOrderAddressRelatedByDeliveryOrderAddressId(null); } return $this; @@ -2300,7 +2373,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2311,12 +2384,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByDeliveryOrderAddressIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Currency', $joinBehavior); - return $this->getOrdersRelatedByAddressDelivery($query, $con); + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); } @@ -2325,7 +2398,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2336,12 +2409,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByDeliveryOrderAddressIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Customer', $joinBehavior); - return $this->getOrdersRelatedByAddressDelivery($query, $con); + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); } @@ -2350,7 +2423,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2361,12 +2434,87 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByDeliveryOrderAddressIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('OrderStatus', $joinBehavior); - return $this->getOrdersRelatedByAddressDelivery($query, $con); + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryOrderAddressIdJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryOrderAddressIdJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryOrderAddressIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); } /** @@ -2407,26 +2555,26 @@ abstract class OrderAddress implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collOrdersRelatedByAddressInvoice) { - foreach ($this->collOrdersRelatedByAddressInvoice as $o) { + if ($this->collOrdersRelatedByInvoiceOrderAddressId) { + foreach ($this->collOrdersRelatedByInvoiceOrderAddressId as $o) { $o->clearAllReferences($deep); } } - if ($this->collOrdersRelatedByAddressDelivery) { - foreach ($this->collOrdersRelatedByAddressDelivery as $o) { + if ($this->collOrdersRelatedByDeliveryOrderAddressId) { + foreach ($this->collOrdersRelatedByDeliveryOrderAddressId as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collOrdersRelatedByAddressInvoice instanceof Collection) { - $this->collOrdersRelatedByAddressInvoice->clearIterator(); + if ($this->collOrdersRelatedByInvoiceOrderAddressId instanceof Collection) { + $this->collOrdersRelatedByInvoiceOrderAddressId->clearIterator(); } - $this->collOrdersRelatedByAddressInvoice = null; - if ($this->collOrdersRelatedByAddressDelivery instanceof Collection) { - $this->collOrdersRelatedByAddressDelivery->clearIterator(); + $this->collOrdersRelatedByInvoiceOrderAddressId = null; + if ($this->collOrdersRelatedByDeliveryOrderAddressId instanceof Collection) { + $this->collOrdersRelatedByDeliveryOrderAddressId->clearIterator(); } - $this->collOrdersRelatedByAddressDelivery = null; + $this->collOrdersRelatedByDeliveryOrderAddressId = null; } /** diff --git a/core/lib/Thelia/Model/Base/OrderAddressQuery.php b/core/lib/Thelia/Model/Base/OrderAddressQuery.php index 0552feb85..41f417872 100644 --- a/core/lib/Thelia/Model/Base/OrderAddressQuery.php +++ b/core/lib/Thelia/Model/Base/OrderAddressQuery.php @@ -55,13 +55,13 @@ use Thelia\Model\Map\OrderAddressTableMap; * @method ChildOrderAddressQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildOrderAddressQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildOrderAddressQuery leftJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByAddressInvoice relation - * @method ChildOrderAddressQuery rightJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByAddressInvoice relation - * @method ChildOrderAddressQuery innerJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByAddressInvoice relation + * @method ChildOrderAddressQuery leftJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation + * @method ChildOrderAddressQuery rightJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation + * @method ChildOrderAddressQuery innerJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation * - * @method ChildOrderAddressQuery leftJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByAddressDelivery relation - * @method ChildOrderAddressQuery rightJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByAddressDelivery relation - * @method ChildOrderAddressQuery innerJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByAddressDelivery relation + * @method ChildOrderAddressQuery leftJoinOrderRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation + * @method ChildOrderAddressQuery rightJoinOrderRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation + * @method ChildOrderAddressQuery innerJoinOrderRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation * * @method ChildOrderAddress findOne(ConnectionInterface $con = null) Return the first ChildOrderAddress matching the query * @method ChildOrderAddress findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderAddress matching the query, or a new ChildOrderAddress object populated from the query conditions when no match is found @@ -750,33 +750,33 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function filterByOrderRelatedByAddressInvoice($order, $comparison = null) + public function filterByOrderRelatedByInvoiceOrderAddressId($order, $comparison = null) { if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressInvoice(), $comparison); + ->addUsingAlias(OrderAddressTableMap::ID, $order->getInvoiceOrderAddressId(), $comparison); } elseif ($order instanceof ObjectCollection) { return $this - ->useOrderRelatedByAddressInvoiceQuery() + ->useOrderRelatedByInvoiceOrderAddressIdQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\Order or Collection'); + throw new PropelException('filterByOrderRelatedByInvoiceOrderAddressId() only accepts arguments of type \Thelia\Model\Order or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderRelatedByAddressInvoice relation + * Adds a JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderRelatedByInvoiceOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderRelatedByAddressInvoice'); + $relationMap = $tableMap->getRelation('OrderRelatedByInvoiceOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -791,14 +791,14 @@ abstract class OrderAddressQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderRelatedByAddressInvoice'); + $this->addJoinObject($join, 'OrderRelatedByInvoiceOrderAddressId'); } return $this; } /** - * Use the OrderRelatedByAddressInvoice relation Order object + * Use the OrderRelatedByInvoiceOrderAddressId relation Order object * * @see useQuery() * @@ -808,11 +808,11 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderRelatedByInvoiceOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderRelatedByAddressInvoice($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressInvoice', '\Thelia\Model\OrderQuery'); + ->joinOrderRelatedByInvoiceOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByInvoiceOrderAddressId', '\Thelia\Model\OrderQuery'); } /** @@ -823,33 +823,33 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function filterByOrderRelatedByAddressDelivery($order, $comparison = null) + public function filterByOrderRelatedByDeliveryOrderAddressId($order, $comparison = null) { if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressDelivery(), $comparison); + ->addUsingAlias(OrderAddressTableMap::ID, $order->getDeliveryOrderAddressId(), $comparison); } elseif ($order instanceof ObjectCollection) { return $this - ->useOrderRelatedByAddressDeliveryQuery() + ->useOrderRelatedByDeliveryOrderAddressIdQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\Order or Collection'); + throw new PropelException('filterByOrderRelatedByDeliveryOrderAddressId() only accepts arguments of type \Thelia\Model\Order or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderRelatedByAddressDelivery relation + * Adds a JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderRelatedByDeliveryOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderRelatedByAddressDelivery'); + $relationMap = $tableMap->getRelation('OrderRelatedByDeliveryOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -864,14 +864,14 @@ abstract class OrderAddressQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderRelatedByAddressDelivery'); + $this->addJoinObject($join, 'OrderRelatedByDeliveryOrderAddressId'); } return $this; } /** - * Use the OrderRelatedByAddressDelivery relation Order object + * Use the OrderRelatedByDeliveryOrderAddressId relation Order object * * @see useQuery() * @@ -881,11 +881,11 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderRelatedByDeliveryOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderRelatedByAddressDelivery($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressDelivery', '\Thelia\Model\OrderQuery'); + ->joinOrderRelatedByDeliveryOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByDeliveryOrderAddressId', '\Thelia\Model\OrderQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php index 2bf9c7ace..6ff03d427 100644 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -18,10 +18,12 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Order as ChildOrder; -use Thelia\Model\OrderFeature as ChildOrderFeature; -use Thelia\Model\OrderFeatureQuery as ChildOrderFeatureQuery; use Thelia\Model\OrderProduct as ChildOrderProduct; +use Thelia\Model\OrderProductAttributeCombination as ChildOrderProductAttributeCombination; +use Thelia\Model\OrderProductAttributeCombinationQuery as ChildOrderProductAttributeCombinationQuery; use Thelia\Model\OrderProductQuery as ChildOrderProductQuery; +use Thelia\Model\OrderProductTax as ChildOrderProductTax; +use Thelia\Model\OrderProductTaxQuery as ChildOrderProductTaxQuery; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\OrderProductTableMap; @@ -77,12 +79,24 @@ abstract class OrderProduct implements ActiveRecordInterface */ protected $product_ref; + /** + * The value for the product_sale_elements_ref field. + * @var string + */ + protected $product_sale_elements_ref; + /** * The value for the title field. * @var string */ protected $title; + /** + * The value for the chapo field. + * @var string + */ + protected $chapo; + /** * The value for the description field. * @var string @@ -90,10 +104,10 @@ abstract class OrderProduct implements ActiveRecordInterface protected $description; /** - * The value for the chapo field. + * The value for the postscriptum field. * @var string */ - protected $chapo; + protected $postscriptum; /** * The value for the quantity field. @@ -108,10 +122,40 @@ abstract class OrderProduct implements ActiveRecordInterface protected $price; /** - * The value for the tax field. - * @var double + * The value for the promo_price field. + * @var string */ - protected $tax; + protected $promo_price; + + /** + * The value for the was_new field. + * @var int + */ + protected $was_new; + + /** + * The value for the was_in_promo field. + * @var int + */ + protected $was_in_promo; + + /** + * The value for the weight field. + * @var string + */ + protected $weight; + + /** + * The value for the tax_rule_title field. + * @var string + */ + protected $tax_rule_title; + + /** + * The value for the tax_rule_description field. + * @var string + */ + protected $tax_rule_description; /** * The value for the parent field. @@ -137,10 +181,16 @@ abstract class OrderProduct implements ActiveRecordInterface protected $aOrder; /** - * @var ObjectCollection|ChildOrderFeature[] Collection to store aggregation of ChildOrderFeature objects. + * @var ObjectCollection|ChildOrderProductAttributeCombination[] Collection to store aggregation of ChildOrderProductAttributeCombination objects. */ - protected $collOrderFeatures; - protected $collOrderFeaturesPartial; + protected $collOrderProductAttributeCombinations; + protected $collOrderProductAttributeCombinationsPartial; + + /** + * @var ObjectCollection|ChildOrderProductTax[] Collection to store aggregation of ChildOrderProductTax objects. + */ + protected $collOrderProductTaxes; + protected $collOrderProductTaxesPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -154,7 +204,13 @@ abstract class OrderProduct implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $orderFeaturesScheduledForDeletion = null; + protected $orderProductAttributeCombinationsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $orderProductTaxesScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\OrderProduct object. @@ -443,6 +499,17 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->product_ref; } + /** + * Get the [product_sale_elements_ref] column value. + * + * @return string + */ + public function getProductSaleElementsRef() + { + + return $this->product_sale_elements_ref; + } + /** * Get the [title] column value. * @@ -454,6 +521,17 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->title; } + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + /** * Get the [description] column value. * @@ -466,14 +544,14 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Get the [chapo] column value. + * Get the [postscriptum] column value. * * @return string */ - public function getChapo() + public function getPostscriptum() { - return $this->chapo; + return $this->postscriptum; } /** @@ -499,19 +577,74 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Get the [tax] column value. + * Get the [promo_price] column value. * - * @return double + * @return string */ - public function getTax() + public function getPromoPrice() { - return $this->tax; + return $this->promo_price; + } + + /** + * Get the [was_new] column value. + * + * @return int + */ + public function getWasNew() + { + + return $this->was_new; + } + + /** + * Get the [was_in_promo] column value. + * + * @return int + */ + public function getWasInPromo() + { + + return $this->was_in_promo; + } + + /** + * Get the [weight] column value. + * + * @return string + */ + public function getWeight() + { + + return $this->weight; + } + + /** + * Get the [tax_rule_title] column value. + * + * @return string + */ + public function getTaxRuleTitle() + { + + return $this->tax_rule_title; + } + + /** + * Get the [tax_rule_description] column value. + * + * @return string + */ + public function getTaxRuleDescription() + { + + return $this->tax_rule_description; } /** * Get the [parent] column value. - * + * not managed yet * @return int */ public function getParent() @@ -627,6 +760,27 @@ abstract class OrderProduct implements ActiveRecordInterface return $this; } // setProductRef() + /** + * Set the value of [product_sale_elements_ref] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setProductSaleElementsRef($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->product_sale_elements_ref !== $v) { + $this->product_sale_elements_ref = $v; + $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF; + } + + + return $this; + } // setProductSaleElementsRef() + /** * Set the value of [title] column. * @@ -648,6 +802,27 @@ abstract class OrderProduct implements ActiveRecordInterface return $this; } // setTitle() + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = OrderProductTableMap::CHAPO; + } + + + return $this; + } // setChapo() + /** * Set the value of [description] column. * @@ -670,25 +845,25 @@ abstract class OrderProduct implements ActiveRecordInterface } // setDescription() /** - * Set the value of [chapo] column. + * Set the value of [postscriptum] column. * * @param string $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function setChapo($v) + public function setPostscriptum($v) { if ($v !== null) { $v = (string) $v; } - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = OrderProductTableMap::CHAPO; + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = OrderProductTableMap::POSTSCRIPTUM; } return $this; - } // setChapo() + } // setPostscriptum() /** * Set the value of [quantity] column. @@ -733,29 +908,134 @@ abstract class OrderProduct implements ActiveRecordInterface } // setPrice() /** - * Set the value of [tax] column. + * Set the value of [promo_price] column. * - * @param double $v new value + * @param string $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function setTax($v) + public function setPromoPrice($v) { if ($v !== null) { - $v = (double) $v; + $v = (string) $v; } - if ($this->tax !== $v) { - $this->tax = $v; - $this->modifiedColumns[] = OrderProductTableMap::TAX; + if ($this->promo_price !== $v) { + $this->promo_price = $v; + $this->modifiedColumns[] = OrderProductTableMap::PROMO_PRICE; } return $this; - } // setTax() + } // setPromoPrice() + + /** + * Set the value of [was_new] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWasNew($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->was_new !== $v) { + $this->was_new = $v; + $this->modifiedColumns[] = OrderProductTableMap::WAS_NEW; + } + + + return $this; + } // setWasNew() + + /** + * Set the value of [was_in_promo] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWasInPromo($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->was_in_promo !== $v) { + $this->was_in_promo = $v; + $this->modifiedColumns[] = OrderProductTableMap::WAS_IN_PROMO; + } + + + return $this; + } // setWasInPromo() + + /** + * Set the value of [weight] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWeight($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->weight !== $v) { + $this->weight = $v; + $this->modifiedColumns[] = OrderProductTableMap::WEIGHT; + } + + + return $this; + } // setWeight() + + /** + * Set the value of [tax_rule_title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTaxRuleTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->tax_rule_title !== $v) { + $this->tax_rule_title = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX_RULE_TITLE; + } + + + return $this; + } // setTaxRuleTitle() + + /** + * Set the value of [tax_rule_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTaxRuleDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->tax_rule_description !== $v) { + $this->tax_rule_description = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX_RULE_DESCRIPTION; + } + + + return $this; + } // setTaxRuleDescription() /** * Set the value of [parent] column. - * + * not managed yet * @param int $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ @@ -862,34 +1142,55 @@ abstract class OrderProduct implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTableMap::translateFieldName('ProductRef', TableMap::TYPE_PHPNAME, $indexType)]; $this->product_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; - $this->title = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('ProductSaleElementsRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_sale_elements_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; - $this->description = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; $this->chapo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; $this->quantity = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; $this->price = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)]; - $this->tax = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo_price = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductTableMap::translateFieldName('WasNew', TableMap::TYPE_PHPNAME, $indexType)]; + $this->was_new = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderProductTableMap::translateFieldName('WasInPromo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->was_in_promo = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; + $this->weight = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; $this->parent = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -902,7 +1203,7 @@ abstract class OrderProduct implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 12; // 12 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 19; // 19 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); @@ -967,7 +1268,9 @@ abstract class OrderProduct implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aOrder = null; - $this->collOrderFeatures = null; + $this->collOrderProductAttributeCombinations = null; + + $this->collOrderProductTaxes = null; } // if (deep) } @@ -1114,17 +1417,34 @@ abstract class OrderProduct implements ActiveRecordInterface $this->resetModified(); } - if ($this->orderFeaturesScheduledForDeletion !== null) { - if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) { - \Thelia\Model\OrderFeatureQuery::create() - ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->orderProductAttributeCombinationsScheduledForDeletion !== null) { + if (!$this->orderProductAttributeCombinationsScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderProductAttributeCombinationQuery::create() + ->filterByPrimaryKeys($this->orderProductAttributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->orderFeaturesScheduledForDeletion = null; + $this->orderProductAttributeCombinationsScheduledForDeletion = null; } } - if ($this->collOrderFeatures !== null) { - foreach ($this->collOrderFeatures as $referrerFK) { + if ($this->collOrderProductAttributeCombinations !== null) { + foreach ($this->collOrderProductAttributeCombinations as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->orderProductTaxesScheduledForDeletion !== null) { + if (!$this->orderProductTaxesScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderProductTaxQuery::create() + ->filterByPrimaryKeys($this->orderProductTaxesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->orderProductTaxesScheduledForDeletion = null; + } + } + + if ($this->collOrderProductTaxes !== null) { + foreach ($this->collOrderProductTaxes as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1166,14 +1486,20 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) { $modifiedColumns[':p' . $index++] = 'PRODUCT_REF'; } + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_REF'; + } if ($this->isColumnModified(OrderProductTableMap::TITLE)) { $modifiedColumns[':p' . $index++] = 'TITLE'; } + if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { - $modifiedColumns[':p' . $index++] = 'CHAPO'; + if ($this->isColumnModified(OrderProductTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) { $modifiedColumns[':p' . $index++] = 'QUANTITY'; @@ -1181,8 +1507,23 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::PRICE)) { $modifiedColumns[':p' . $index++] = 'PRICE'; } - if ($this->isColumnModified(OrderProductTableMap::TAX)) { - $modifiedColumns[':p' . $index++] = 'TAX'; + if ($this->isColumnModified(OrderProductTableMap::PROMO_PRICE)) { + $modifiedColumns[':p' . $index++] = 'PROMO_PRICE'; + } + if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) { + $modifiedColumns[':p' . $index++] = 'WAS_NEW'; + } + if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) { + $modifiedColumns[':p' . $index++] = 'WAS_IN_PROMO'; + } + if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) { + $modifiedColumns[':p' . $index++] = 'WEIGHT'; + } + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_TITLE'; + } + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_DESCRIPTION'; } if ($this->isColumnModified(OrderProductTableMap::PARENT)) { $modifiedColumns[':p' . $index++] = 'PARENT'; @@ -1213,14 +1554,20 @@ abstract class OrderProduct implements ActiveRecordInterface case 'PRODUCT_REF': $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); break; + case 'PRODUCT_SALE_ELEMENTS_REF': + $stmt->bindValue($identifier, $this->product_sale_elements_ref, PDO::PARAM_STR); + break; case 'TITLE': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case 'CHAPO': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); @@ -1228,8 +1575,23 @@ abstract class OrderProduct implements ActiveRecordInterface case 'PRICE': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case 'TAX': - $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); + case 'PROMO_PRICE': + $stmt->bindValue($identifier, $this->promo_price, PDO::PARAM_STR); + break; + case 'WAS_NEW': + $stmt->bindValue($identifier, $this->was_new, PDO::PARAM_INT); + break; + case 'WAS_IN_PROMO': + $stmt->bindValue($identifier, $this->was_in_promo, PDO::PARAM_INT); + break; + case 'WEIGHT': + $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); + break; + case 'TAX_RULE_TITLE': + $stmt->bindValue($identifier, $this->tax_rule_title, PDO::PARAM_STR); + break; + case 'TAX_RULE_DESCRIPTION': + $stmt->bindValue($identifier, $this->tax_rule_description, PDO::PARAM_STR); break; case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); @@ -1312,30 +1674,51 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->getProductRef(); break; case 3: - return $this->getTitle(); + return $this->getProductSaleElementsRef(); break; case 4: - return $this->getDescription(); + return $this->getTitle(); break; case 5: return $this->getChapo(); break; case 6: - return $this->getQuantity(); + return $this->getDescription(); break; case 7: - return $this->getPrice(); + return $this->getPostscriptum(); break; case 8: - return $this->getTax(); + return $this->getQuantity(); break; case 9: - return $this->getParent(); + return $this->getPrice(); break; case 10: - return $this->getCreatedAt(); + return $this->getPromoPrice(); break; case 11: + return $this->getWasNew(); + break; + case 12: + return $this->getWasInPromo(); + break; + case 13: + return $this->getWeight(); + break; + case 14: + return $this->getTaxRuleTitle(); + break; + case 15: + return $this->getTaxRuleDescription(); + break; + case 16: + return $this->getParent(); + break; + case 17: + return $this->getCreatedAt(); + break; + case 18: return $this->getUpdatedAt(); break; default: @@ -1370,15 +1753,22 @@ abstract class OrderProduct implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getOrderId(), $keys[2] => $this->getProductRef(), - $keys[3] => $this->getTitle(), - $keys[4] => $this->getDescription(), + $keys[3] => $this->getProductSaleElementsRef(), + $keys[4] => $this->getTitle(), $keys[5] => $this->getChapo(), - $keys[6] => $this->getQuantity(), - $keys[7] => $this->getPrice(), - $keys[8] => $this->getTax(), - $keys[9] => $this->getParent(), - $keys[10] => $this->getCreatedAt(), - $keys[11] => $this->getUpdatedAt(), + $keys[6] => $this->getDescription(), + $keys[7] => $this->getPostscriptum(), + $keys[8] => $this->getQuantity(), + $keys[9] => $this->getPrice(), + $keys[10] => $this->getPromoPrice(), + $keys[11] => $this->getWasNew(), + $keys[12] => $this->getWasInPromo(), + $keys[13] => $this->getWeight(), + $keys[14] => $this->getTaxRuleTitle(), + $keys[15] => $this->getTaxRuleDescription(), + $keys[16] => $this->getParent(), + $keys[17] => $this->getCreatedAt(), + $keys[18] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1390,8 +1780,11 @@ abstract class OrderProduct implements ActiveRecordInterface if (null !== $this->aOrder) { $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->collOrderFeatures) { - $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrderProductAttributeCombinations) { + $result['OrderProductAttributeCombinations'] = $this->collOrderProductAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collOrderProductTaxes) { + $result['OrderProductTaxes'] = $this->collOrderProductTaxes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1437,30 +1830,51 @@ abstract class OrderProduct implements ActiveRecordInterface $this->setProductRef($value); break; case 3: - $this->setTitle($value); + $this->setProductSaleElementsRef($value); break; case 4: - $this->setDescription($value); + $this->setTitle($value); break; case 5: $this->setChapo($value); break; case 6: - $this->setQuantity($value); + $this->setDescription($value); break; case 7: - $this->setPrice($value); + $this->setPostscriptum($value); break; case 8: - $this->setTax($value); + $this->setQuantity($value); break; case 9: - $this->setParent($value); + $this->setPrice($value); break; case 10: - $this->setCreatedAt($value); + $this->setPromoPrice($value); break; case 11: + $this->setWasNew($value); + break; + case 12: + $this->setWasInPromo($value); + break; + case 13: + $this->setWeight($value); + break; + case 14: + $this->setTaxRuleTitle($value); + break; + case 15: + $this->setTaxRuleDescription($value); + break; + case 16: + $this->setParent($value); + break; + case 17: + $this->setCreatedAt($value); + break; + case 18: $this->setUpdatedAt($value); break; } // switch() @@ -1490,15 +1904,22 @@ abstract class OrderProduct implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setProductSaleElementsRef($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setTitle($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setQuantity($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setPrice($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTax($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setParent($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); + if (array_key_exists($keys[6], $arr)) $this->setDescription($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setPostscriptum($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setPrice($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setPromoPrice($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setWasNew($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setWasInPromo($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setWeight($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setTaxRuleTitle($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setTaxRuleDescription($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setParent($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]); } /** @@ -1513,12 +1934,19 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::ID)) $criteria->add(OrderProductTableMap::ID, $this->id); if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) $criteria->add(OrderProductTableMap::ORDER_ID, $this->order_id); if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) $criteria->add(OrderProductTableMap::PRODUCT_REF, $this->product_ref); + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF)) $criteria->add(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $this->product_sale_elements_ref); if ($this->isColumnModified(OrderProductTableMap::TITLE)) $criteria->add(OrderProductTableMap::TITLE, $this->title); - if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(OrderProductTableMap::CHAPO)) $criteria->add(OrderProductTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderProductTableMap::POSTSCRIPTUM)) $criteria->add(OrderProductTableMap::POSTSCRIPTUM, $this->postscriptum); if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) $criteria->add(OrderProductTableMap::QUANTITY, $this->quantity); if ($this->isColumnModified(OrderProductTableMap::PRICE)) $criteria->add(OrderProductTableMap::PRICE, $this->price); - if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax); + if ($this->isColumnModified(OrderProductTableMap::PROMO_PRICE)) $criteria->add(OrderProductTableMap::PROMO_PRICE, $this->promo_price); + if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) $criteria->add(OrderProductTableMap::WAS_NEW, $this->was_new); + if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) $criteria->add(OrderProductTableMap::WAS_IN_PROMO, $this->was_in_promo); + if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) $criteria->add(OrderProductTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) $criteria->add(OrderProductTableMap::TAX_RULE_TITLE, $this->tax_rule_title); + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) $criteria->add(OrderProductTableMap::TAX_RULE_DESCRIPTION, $this->tax_rule_description); if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::UPDATED_AT, $this->updated_at); @@ -1587,12 +2015,19 @@ abstract class OrderProduct implements ActiveRecordInterface { $copyObj->setOrderId($this->getOrderId()); $copyObj->setProductRef($this->getProductRef()); + $copyObj->setProductSaleElementsRef($this->getProductSaleElementsRef()); $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setPostscriptum($this->getPostscriptum()); $copyObj->setQuantity($this->getQuantity()); $copyObj->setPrice($this->getPrice()); - $copyObj->setTax($this->getTax()); + $copyObj->setPromoPrice($this->getPromoPrice()); + $copyObj->setWasNew($this->getWasNew()); + $copyObj->setWasInPromo($this->getWasInPromo()); + $copyObj->setWeight($this->getWeight()); + $copyObj->setTaxRuleTitle($this->getTaxRuleTitle()); + $copyObj->setTaxRuleDescription($this->getTaxRuleDescription()); $copyObj->setParent($this->getParent()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1602,9 +2037,15 @@ abstract class OrderProduct implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getOrderFeatures() as $relObj) { + foreach ($this->getOrderProductAttributeCombinations() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderFeature($relObj->copy($deepCopy)); + $copyObj->addOrderProductAttributeCombination($relObj->copy($deepCopy)); + } + } + + foreach ($this->getOrderProductTaxes() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderProductTax($relObj->copy($deepCopy)); } } @@ -1700,37 +2141,40 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('OrderFeature' == $relationName) { - return $this->initOrderFeatures(); + if ('OrderProductAttributeCombination' == $relationName) { + return $this->initOrderProductAttributeCombinations(); + } + if ('OrderProductTax' == $relationName) { + return $this->initOrderProductTaxes(); } } /** - * Clears out the collOrderFeatures collection + * Clears out the collOrderProductAttributeCombinations collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addOrderFeatures() + * @see addOrderProductAttributeCombinations() */ - public function clearOrderFeatures() + public function clearOrderProductAttributeCombinations() { - $this->collOrderFeatures = null; // important to set this to NULL since that means it is uninitialized + $this->collOrderProductAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrderFeatures collection loaded partially. + * Reset is the collOrderProductAttributeCombinations collection loaded partially. */ - public function resetPartialOrderFeatures($v = true) + public function resetPartialOrderProductAttributeCombinations($v = true) { - $this->collOrderFeaturesPartial = $v; + $this->collOrderProductAttributeCombinationsPartial = $v; } /** - * Initializes the collOrderFeatures collection. + * Initializes the collOrderProductAttributeCombinations collection. * - * By default this just sets the collOrderFeatures collection to an empty array (like clearcollOrderFeatures()); + * By default this just sets the collOrderProductAttributeCombinations collection to an empty array (like clearcollOrderProductAttributeCombinations()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1739,17 +2183,17 @@ abstract class OrderProduct implements ActiveRecordInterface * * @return void */ - public function initOrderFeatures($overrideExisting = true) + public function initOrderProductAttributeCombinations($overrideExisting = true) { - if (null !== $this->collOrderFeatures && !$overrideExisting) { + if (null !== $this->collOrderProductAttributeCombinations && !$overrideExisting) { return; } - $this->collOrderFeatures = new ObjectCollection(); - $this->collOrderFeatures->setModel('\Thelia\Model\OrderFeature'); + $this->collOrderProductAttributeCombinations = new ObjectCollection(); + $this->collOrderProductAttributeCombinations->setModel('\Thelia\Model\OrderProductAttributeCombination'); } /** - * Gets an array of ChildOrderFeature objects which contain a foreign key that references this object. + * Gets an array of ChildOrderProductAttributeCombination objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1759,109 +2203,109 @@ abstract class OrderProduct implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildOrderFeature[] List of ChildOrderFeature objects + * @return Collection|ChildOrderProductAttributeCombination[] List of ChildOrderProductAttributeCombination objects * @throws PropelException */ - public function getOrderFeatures($criteria = null, ConnectionInterface $con = null) + public function getOrderProductAttributeCombinations($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { + $partial = $this->collOrderProductAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderProductAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductAttributeCombinations) { // return empty collection - $this->initOrderFeatures(); + $this->initOrderProductAttributeCombinations(); } else { - $collOrderFeatures = ChildOrderFeatureQuery::create(null, $criteria) + $collOrderProductAttributeCombinations = ChildOrderProductAttributeCombinationQuery::create(null, $criteria) ->filterByOrderProduct($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) { - $this->initOrderFeatures(false); + if (false !== $this->collOrderProductAttributeCombinationsPartial && count($collOrderProductAttributeCombinations)) { + $this->initOrderProductAttributeCombinations(false); - foreach ($collOrderFeatures as $obj) { - if (false == $this->collOrderFeatures->contains($obj)) { - $this->collOrderFeatures->append($obj); + foreach ($collOrderProductAttributeCombinations as $obj) { + if (false == $this->collOrderProductAttributeCombinations->contains($obj)) { + $this->collOrderProductAttributeCombinations->append($obj); } } - $this->collOrderFeaturesPartial = true; + $this->collOrderProductAttributeCombinationsPartial = true; } - $collOrderFeatures->getInternalIterator()->rewind(); + $collOrderProductAttributeCombinations->getInternalIterator()->rewind(); - return $collOrderFeatures; + return $collOrderProductAttributeCombinations; } - if ($partial && $this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $obj) { + if ($partial && $this->collOrderProductAttributeCombinations) { + foreach ($this->collOrderProductAttributeCombinations as $obj) { if ($obj->isNew()) { - $collOrderFeatures[] = $obj; + $collOrderProductAttributeCombinations[] = $obj; } } } - $this->collOrderFeatures = $collOrderFeatures; - $this->collOrderFeaturesPartial = false; + $this->collOrderProductAttributeCombinations = $collOrderProductAttributeCombinations; + $this->collOrderProductAttributeCombinationsPartial = false; } } - return $this->collOrderFeatures; + return $this->collOrderProductAttributeCombinations; } /** - * Sets a collection of OrderFeature objects related by a one-to-many relationship + * Sets a collection of OrderProductAttributeCombination objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $orderFeatures A Propel collection. + * @param Collection $orderProductAttributeCombinations A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderProduct The current object (for fluent API support) */ - public function setOrderFeatures(Collection $orderFeatures, ConnectionInterface $con = null) + public function setOrderProductAttributeCombinations(Collection $orderProductAttributeCombinations, ConnectionInterface $con = null) { - $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); + $orderProductAttributeCombinationsToDelete = $this->getOrderProductAttributeCombinations(new Criteria(), $con)->diff($orderProductAttributeCombinations); - $this->orderFeaturesScheduledForDeletion = $orderFeaturesToDelete; + $this->orderProductAttributeCombinationsScheduledForDeletion = $orderProductAttributeCombinationsToDelete; - foreach ($orderFeaturesToDelete as $orderFeatureRemoved) { - $orderFeatureRemoved->setOrderProduct(null); + foreach ($orderProductAttributeCombinationsToDelete as $orderProductAttributeCombinationRemoved) { + $orderProductAttributeCombinationRemoved->setOrderProduct(null); } - $this->collOrderFeatures = null; - foreach ($orderFeatures as $orderFeature) { - $this->addOrderFeature($orderFeature); + $this->collOrderProductAttributeCombinations = null; + foreach ($orderProductAttributeCombinations as $orderProductAttributeCombination) { + $this->addOrderProductAttributeCombination($orderProductAttributeCombination); } - $this->collOrderFeatures = $orderFeatures; - $this->collOrderFeaturesPartial = false; + $this->collOrderProductAttributeCombinations = $orderProductAttributeCombinations; + $this->collOrderProductAttributeCombinationsPartial = false; return $this; } /** - * Returns the number of related OrderFeature objects. + * Returns the number of related OrderProductAttributeCombination objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related OrderFeature objects. + * @return int Count of related OrderProductAttributeCombination objects. * @throws PropelException */ - public function countOrderFeatures(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrderProductAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { + $partial = $this->collOrderProductAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderProductAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductAttributeCombinations) { return 0; } if ($partial && !$criteria) { - return count($this->getOrderFeatures()); + return count($this->getOrderProductAttributeCombinations()); } - $query = ChildOrderFeatureQuery::create(null, $criteria); + $query = ChildOrderProductAttributeCombinationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1871,53 +2315,271 @@ abstract class OrderProduct implements ActiveRecordInterface ->count($con); } - return count($this->collOrderFeatures); + return count($this->collOrderProductAttributeCombinations); } /** - * Method called to associate a ChildOrderFeature object to this object - * through the ChildOrderFeature foreign key attribute. + * Method called to associate a ChildOrderProductAttributeCombination object to this object + * through the ChildOrderProductAttributeCombination foreign key attribute. * - * @param ChildOrderFeature $l ChildOrderFeature + * @param ChildOrderProductAttributeCombination $l ChildOrderProductAttributeCombination * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function addOrderFeature(ChildOrderFeature $l) + public function addOrderProductAttributeCombination(ChildOrderProductAttributeCombination $l) { - if ($this->collOrderFeatures === null) { - $this->initOrderFeatures(); - $this->collOrderFeaturesPartial = true; + if ($this->collOrderProductAttributeCombinations === null) { + $this->initOrderProductAttributeCombinations(); + $this->collOrderProductAttributeCombinationsPartial = true; } - if (!in_array($l, $this->collOrderFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderFeature($l); + if (!in_array($l, $this->collOrderProductAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderProductAttributeCombination($l); } return $this; } /** - * @param OrderFeature $orderFeature The orderFeature object to add. + * @param OrderProductAttributeCombination $orderProductAttributeCombination The orderProductAttributeCombination object to add. */ - protected function doAddOrderFeature($orderFeature) + protected function doAddOrderProductAttributeCombination($orderProductAttributeCombination) { - $this->collOrderFeatures[]= $orderFeature; - $orderFeature->setOrderProduct($this); + $this->collOrderProductAttributeCombinations[]= $orderProductAttributeCombination; + $orderProductAttributeCombination->setOrderProduct($this); } /** - * @param OrderFeature $orderFeature The orderFeature object to remove. + * @param OrderProductAttributeCombination $orderProductAttributeCombination The orderProductAttributeCombination object to remove. * @return ChildOrderProduct The current object (for fluent API support) */ - public function removeOrderFeature($orderFeature) + public function removeOrderProductAttributeCombination($orderProductAttributeCombination) { - if ($this->getOrderFeatures()->contains($orderFeature)) { - $this->collOrderFeatures->remove($this->collOrderFeatures->search($orderFeature)); - if (null === $this->orderFeaturesScheduledForDeletion) { - $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures; - $this->orderFeaturesScheduledForDeletion->clear(); + if ($this->getOrderProductAttributeCombinations()->contains($orderProductAttributeCombination)) { + $this->collOrderProductAttributeCombinations->remove($this->collOrderProductAttributeCombinations->search($orderProductAttributeCombination)); + if (null === $this->orderProductAttributeCombinationsScheduledForDeletion) { + $this->orderProductAttributeCombinationsScheduledForDeletion = clone $this->collOrderProductAttributeCombinations; + $this->orderProductAttributeCombinationsScheduledForDeletion->clear(); } - $this->orderFeaturesScheduledForDeletion[]= clone $orderFeature; - $orderFeature->setOrderProduct(null); + $this->orderProductAttributeCombinationsScheduledForDeletion[]= clone $orderProductAttributeCombination; + $orderProductAttributeCombination->setOrderProduct(null); + } + + return $this; + } + + /** + * Clears out the collOrderProductTaxes collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrderProductTaxes() + */ + public function clearOrderProductTaxes() + { + $this->collOrderProductTaxes = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrderProductTaxes collection loaded partially. + */ + public function resetPartialOrderProductTaxes($v = true) + { + $this->collOrderProductTaxesPartial = $v; + } + + /** + * Initializes the collOrderProductTaxes collection. + * + * By default this just sets the collOrderProductTaxes collection to an empty array (like clearcollOrderProductTaxes()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrderProductTaxes($overrideExisting = true) + { + if (null !== $this->collOrderProductTaxes && !$overrideExisting) { + return; + } + $this->collOrderProductTaxes = new ObjectCollection(); + $this->collOrderProductTaxes->setModel('\Thelia\Model\OrderProductTax'); + } + + /** + * Gets an array of ChildOrderProductTax objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildOrderProduct is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderProductTax[] List of ChildOrderProductTax objects + * @throws PropelException + */ + public function getOrderProductTaxes($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrderProductTaxesPartial && !$this->isNew(); + if (null === $this->collOrderProductTaxes || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductTaxes) { + // return empty collection + $this->initOrderProductTaxes(); + } else { + $collOrderProductTaxes = ChildOrderProductTaxQuery::create(null, $criteria) + ->filterByOrderProduct($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrderProductTaxesPartial && count($collOrderProductTaxes)) { + $this->initOrderProductTaxes(false); + + foreach ($collOrderProductTaxes as $obj) { + if (false == $this->collOrderProductTaxes->contains($obj)) { + $this->collOrderProductTaxes->append($obj); + } + } + + $this->collOrderProductTaxesPartial = true; + } + + $collOrderProductTaxes->getInternalIterator()->rewind(); + + return $collOrderProductTaxes; + } + + if ($partial && $this->collOrderProductTaxes) { + foreach ($this->collOrderProductTaxes as $obj) { + if ($obj->isNew()) { + $collOrderProductTaxes[] = $obj; + } + } + } + + $this->collOrderProductTaxes = $collOrderProductTaxes; + $this->collOrderProductTaxesPartial = false; + } + } + + return $this->collOrderProductTaxes; + } + + /** + * Sets a collection of OrderProductTax objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $orderProductTaxes A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function setOrderProductTaxes(Collection $orderProductTaxes, ConnectionInterface $con = null) + { + $orderProductTaxesToDelete = $this->getOrderProductTaxes(new Criteria(), $con)->diff($orderProductTaxes); + + + $this->orderProductTaxesScheduledForDeletion = $orderProductTaxesToDelete; + + foreach ($orderProductTaxesToDelete as $orderProductTaxRemoved) { + $orderProductTaxRemoved->setOrderProduct(null); + } + + $this->collOrderProductTaxes = null; + foreach ($orderProductTaxes as $orderProductTax) { + $this->addOrderProductTax($orderProductTax); + } + + $this->collOrderProductTaxes = $orderProductTaxes; + $this->collOrderProductTaxesPartial = false; + + return $this; + } + + /** + * Returns the number of related OrderProductTax objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related OrderProductTax objects. + * @throws PropelException + */ + public function countOrderProductTaxes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrderProductTaxesPartial && !$this->isNew(); + if (null === $this->collOrderProductTaxes || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductTaxes) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrderProductTaxes()); + } + + $query = ChildOrderProductTaxQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderProduct($this) + ->count($con); + } + + return count($this->collOrderProductTaxes); + } + + /** + * Method called to associate a ChildOrderProductTax object to this object + * through the ChildOrderProductTax foreign key attribute. + * + * @param ChildOrderProductTax $l ChildOrderProductTax + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function addOrderProductTax(ChildOrderProductTax $l) + { + if ($this->collOrderProductTaxes === null) { + $this->initOrderProductTaxes(); + $this->collOrderProductTaxesPartial = true; + } + + if (!in_array($l, $this->collOrderProductTaxes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderProductTax($l); + } + + return $this; + } + + /** + * @param OrderProductTax $orderProductTax The orderProductTax object to add. + */ + protected function doAddOrderProductTax($orderProductTax) + { + $this->collOrderProductTaxes[]= $orderProductTax; + $orderProductTax->setOrderProduct($this); + } + + /** + * @param OrderProductTax $orderProductTax The orderProductTax object to remove. + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function removeOrderProductTax($orderProductTax) + { + if ($this->getOrderProductTaxes()->contains($orderProductTax)) { + $this->collOrderProductTaxes->remove($this->collOrderProductTaxes->search($orderProductTax)); + if (null === $this->orderProductTaxesScheduledForDeletion) { + $this->orderProductTaxesScheduledForDeletion = clone $this->collOrderProductTaxes; + $this->orderProductTaxesScheduledForDeletion->clear(); + } + $this->orderProductTaxesScheduledForDeletion[]= clone $orderProductTax; + $orderProductTax->setOrderProduct(null); } return $this; @@ -1931,12 +2593,19 @@ abstract class OrderProduct implements ActiveRecordInterface $this->id = null; $this->order_id = null; $this->product_ref = null; + $this->product_sale_elements_ref = null; $this->title = null; - $this->description = null; $this->chapo = null; + $this->description = null; + $this->postscriptum = null; $this->quantity = null; $this->price = null; - $this->tax = null; + $this->promo_price = null; + $this->was_new = null; + $this->was_in_promo = null; + $this->weight = null; + $this->tax_rule_title = null; + $this->tax_rule_description = null; $this->parent = null; $this->created_at = null; $this->updated_at = null; @@ -1959,17 +2628,26 @@ abstract class OrderProduct implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $o) { + if ($this->collOrderProductAttributeCombinations) { + foreach ($this->collOrderProductAttributeCombinations as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collOrderProductTaxes) { + foreach ($this->collOrderProductTaxes as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collOrderFeatures instanceof Collection) { - $this->collOrderFeatures->clearIterator(); + if ($this->collOrderProductAttributeCombinations instanceof Collection) { + $this->collOrderProductAttributeCombinations->clearIterator(); } - $this->collOrderFeatures = null; + $this->collOrderProductAttributeCombinations = null; + if ($this->collOrderProductTaxes instanceof Collection) { + $this->collOrderProductTaxes->clearIterator(); + } + $this->collOrderProductTaxes = null; $this->aOrder = null; } diff --git a/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php b/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php new file mode 100644 index 000000000..e02bc9cc5 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php @@ -0,0 +1,1824 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderProductAttributeCombination instance. If + * obj is an instance of OrderProductAttributeCombination, delegates to + * equals(OrderProductAttributeCombination). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderProductAttributeCombination The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderProductAttributeCombination The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [order_product_id] column value. + * + * @return int + */ + public function getOrderProductId() + { + + return $this->order_product_id; + } + + /** + * Get the [attribute_title] column value. + * + * @return string + */ + public function getAttributeTitle() + { + + return $this->attribute_title; + } + + /** + * Get the [attribute_chapo] column value. + * + * @return string + */ + public function getAttributeChapo() + { + + return $this->attribute_chapo; + } + + /** + * Get the [attribute_description] column value. + * + * @return string + */ + public function getAttributeDescription() + { + + return $this->attribute_description; + } + + /** + * Get the [attribute_postscriptumn] column value. + * + * @return string + */ + public function getAttributePostscriptumn() + { + + return $this->attribute_postscriptumn; + } + + /** + * Get the [attribute_av_title] column value. + * + * @return string + */ + public function getAttributeAvTitle() + { + + return $this->attribute_av_title; + } + + /** + * Get the [attribute_av_chapo] column value. + * + * @return string + */ + public function getAttributeAvChapo() + { + + return $this->attribute_av_chapo; + } + + /** + * Get the [attribute_av_description] column value. + * + * @return string + */ + public function getAttributeAvDescription() + { + + return $this->attribute_av_description; + } + + /** + * Get the [attribute_av_postscriptum] column value. + * + * @return string + */ + public function getAttributeAvPostscriptum() + { + + return $this->attribute_av_postscriptum; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setOrderProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_product_id !== $v) { + $this->order_product_id = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID; + } + + if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { + $this->aOrderProduct = null; + } + + + return $this; + } // setOrderProductId() + + /** + * Set the value of [attribute_title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_title !== $v) { + $this->attribute_title = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE; + } + + + return $this; + } // setAttributeTitle() + + /** + * Set the value of [attribute_chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_chapo !== $v) { + $this->attribute_chapo = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO; + } + + + return $this; + } // setAttributeChapo() + + /** + * Set the value of [attribute_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_description !== $v) { + $this->attribute_description = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION; + } + + + return $this; + } // setAttributeDescription() + + /** + * Set the value of [attribute_postscriptumn] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributePostscriptumn($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_postscriptumn !== $v) { + $this->attribute_postscriptumn = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN; + } + + + return $this; + } // setAttributePostscriptumn() + + /** + * Set the value of [attribute_av_title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_title !== $v) { + $this->attribute_av_title = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE; + } + + + return $this; + } // setAttributeAvTitle() + + /** + * Set the value of [attribute_av_chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_chapo !== $v) { + $this->attribute_av_chapo = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO; + } + + + return $this; + } // setAttributeAvChapo() + + /** + * Set the value of [attribute_av_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_description !== $v) { + $this->attribute_av_description = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION; + } + + + return $this; + } // setAttributeAvDescription() + + /** + * Set the value of [attribute_av_postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_postscriptum !== $v) { + $this->attribute_av_postscriptum = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM; + } + + + return $this; + } // setAttributeAvPostscriptum() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeChapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributePostscriptumn', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_postscriptumn = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvChapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvPostscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 12; // 12 = OrderProductAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderProductAttributeCombination object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { + $this->aOrderProduct = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderProductAttributeCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrderProduct = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderProductAttributeCombination::setDeleted() + * @see OrderProductAttributeCombination::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderProductAttributeCombinationQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderProductAttributeCombinationTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + OrderProductAttributeCombinationTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aOrderProduct !== null) { + if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { + $affectedRows += $this->aOrderProduct->save($con); + } + $this->setOrderProduct($this->aOrderProduct); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductAttributeCombinationTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_TITLE'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_CHAPO'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_POSTSCRIPTUMN'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_TITLE'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_CHAPO'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_POSTSCRIPTUM'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO order_product_attribute_combination (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'ORDER_PRODUCT_ID': + $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); + break; + case 'ATTRIBUTE_TITLE': + $stmt->bindValue($identifier, $this->attribute_title, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_CHAPO': + $stmt->bindValue($identifier, $this->attribute_chapo, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_DESCRIPTION': + $stmt->bindValue($identifier, $this->attribute_description, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_POSTSCRIPTUMN': + $stmt->bindValue($identifier, $this->attribute_postscriptumn, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_TITLE': + $stmt->bindValue($identifier, $this->attribute_av_title, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_CHAPO': + $stmt->bindValue($identifier, $this->attribute_av_chapo, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_DESCRIPTION': + $stmt->bindValue($identifier, $this->attribute_av_description, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->attribute_av_postscriptum, PDO::PARAM_STR); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getOrderProductId(); + break; + case 2: + return $this->getAttributeTitle(); + break; + case 3: + return $this->getAttributeChapo(); + break; + case 4: + return $this->getAttributeDescription(); + break; + case 5: + return $this->getAttributePostscriptumn(); + break; + case 6: + return $this->getAttributeAvTitle(); + break; + case 7: + return $this->getAttributeAvChapo(); + break; + case 8: + return $this->getAttributeAvDescription(); + break; + case 9: + return $this->getAttributeAvPostscriptum(); + break; + case 10: + return $this->getCreatedAt(); + break; + case 11: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderProductAttributeCombination'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderProductAttributeCombination'][$this->getPrimaryKey()] = true; + $keys = OrderProductAttributeCombinationTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getOrderProductId(), + $keys[2] => $this->getAttributeTitle(), + $keys[3] => $this->getAttributeChapo(), + $keys[4] => $this->getAttributeDescription(), + $keys[5] => $this->getAttributePostscriptumn(), + $keys[6] => $this->getAttributeAvTitle(), + $keys[7] => $this->getAttributeAvChapo(), + $keys[8] => $this->getAttributeAvDescription(), + $keys[9] => $this->getAttributeAvPostscriptum(), + $keys[10] => $this->getCreatedAt(), + $keys[11] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aOrderProduct) { + $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setOrderProductId($value); + break; + case 2: + $this->setAttributeTitle($value); + break; + case 3: + $this->setAttributeChapo($value); + break; + case 4: + $this->setAttributeDescription($value); + break; + case 5: + $this->setAttributePostscriptumn($value); + break; + case 6: + $this->setAttributeAvTitle($value); + break; + case 7: + $this->setAttributeAvChapo($value); + break; + case 8: + $this->setAttributeAvDescription($value); + break; + case 9: + $this->setAttributeAvPostscriptum($value); + break; + case 10: + $this->setCreatedAt($value); + break; + case 11: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = OrderProductAttributeCombinationTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setAttributeTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setAttributeChapo($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAttributeDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setAttributePostscriptumn($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setAttributeAvTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setAttributeAvChapo($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setAttributeAvDescription($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setAttributeAvPostscriptum($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ID)) $criteria->add(OrderProductAttributeCombinationTableMap::ID, $this->id); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $this->order_product_id); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, $this->attribute_title); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $this->attribute_chapo); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $this->attribute_description); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $this->attribute_postscriptumn); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $this->attribute_av_title); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $this->attribute_av_chapo); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $this->attribute_av_description); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $this->attribute_av_postscriptum); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::CREATED_AT)) $criteria->add(OrderProductAttributeCombinationTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) $criteria->add(OrderProductAttributeCombinationTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(OrderProductAttributeCombinationTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\OrderProductAttributeCombination (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setOrderProductId($this->getOrderProductId()); + $copyObj->setAttributeTitle($this->getAttributeTitle()); + $copyObj->setAttributeChapo($this->getAttributeChapo()); + $copyObj->setAttributeDescription($this->getAttributeDescription()); + $copyObj->setAttributePostscriptumn($this->getAttributePostscriptumn()); + $copyObj->setAttributeAvTitle($this->getAttributeAvTitle()); + $copyObj->setAttributeAvChapo($this->getAttributeAvChapo()); + $copyObj->setAttributeAvDescription($this->getAttributeAvDescription()); + $copyObj->setAttributeAvPostscriptum($this->getAttributeAvPostscriptum()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderProductAttributeCombination Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildOrderProduct object. + * + * @param ChildOrderProduct $v + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + * @throws PropelException + */ + public function setOrderProduct(ChildOrderProduct $v = null) + { + if ($v === null) { + $this->setOrderProductId(NULL); + } else { + $this->setOrderProductId($v->getId()); + } + + $this->aOrderProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildOrderProduct object, it will not be re-added. + if ($v !== null) { + $v->addOrderProductAttributeCombination($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrderProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderProduct The associated ChildOrderProduct object. + * @throws PropelException + */ + public function getOrderProduct(ConnectionInterface $con = null) + { + if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aOrderProduct->addOrderProductAttributeCombinations($this); + */ + } + + return $this->aOrderProduct; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->order_product_id = null; + $this->attribute_title = null; + $this->attribute_chapo = null; + $this->attribute_description = null; + $this->attribute_postscriptumn = null; + $this->attribute_av_title = null; + $this->attribute_av_chapo = null; + $this->attribute_av_description = null; + $this->attribute_av_postscriptum = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrderProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderProductAttributeCombinationTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildOrderProductAttributeCombination The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php new file mode 100644 index 000000000..9e8298aa5 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php @@ -0,0 +1,897 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderProductAttributeCombination|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderProductAttributeCombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductAttributeCombination A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_PRODUCT_ID, ATTRIBUTE_TITLE, ATTRIBUTE_CHAPO, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_POSTSCRIPTUMN, ATTRIBUTE_AV_TITLE, ATTRIBUTE_AV_CHAPO, ATTRIBUTE_AV_DESCRIPTION, ATTRIBUTE_AV_POSTSCRIPTUM, CREATED_AT, UPDATED_AT FROM order_product_attribute_combination WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderProductAttributeCombination(); + $obj->hydrate($row); + OrderProductAttributeCombinationTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductAttributeCombination|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_product_id column + * + * Example usage: + * + * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 + * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 + * + * + * @see filterByOrderProduct() + * + * @param mixed $orderProductId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByOrderProductId($orderProductId = null, $comparison = null) + { + if (is_array($orderProductId)) { + $useMinMax = false; + if (isset($orderProductId['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderProductId['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); + } + + /** + * Filter the query on the attribute_title column + * + * Example usage: + * + * $query->filterByAttributeTitle('fooValue'); // WHERE attribute_title = 'fooValue' + * $query->filterByAttributeTitle('%fooValue%'); // WHERE attribute_title LIKE '%fooValue%' + * + * + * @param string $attributeTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeTitle($attributeTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeTitle)) { + $attributeTitle = str_replace('*', '%', $attributeTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, $attributeTitle, $comparison); + } + + /** + * Filter the query on the attribute_chapo column + * + * Example usage: + * + * $query->filterByAttributeChapo('fooValue'); // WHERE attribute_chapo = 'fooValue' + * $query->filterByAttributeChapo('%fooValue%'); // WHERE attribute_chapo LIKE '%fooValue%' + * + * + * @param string $attributeChapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeChapo($attributeChapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeChapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeChapo)) { + $attributeChapo = str_replace('*', '%', $attributeChapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $attributeChapo, $comparison); + } + + /** + * Filter the query on the attribute_description column + * + * Example usage: + * + * $query->filterByAttributeDescription('fooValue'); // WHERE attribute_description = 'fooValue' + * $query->filterByAttributeDescription('%fooValue%'); // WHERE attribute_description LIKE '%fooValue%' + * + * + * @param string $attributeDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeDescription($attributeDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeDescription)) { + $attributeDescription = str_replace('*', '%', $attributeDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $attributeDescription, $comparison); + } + + /** + * Filter the query on the attribute_postscriptumn column + * + * Example usage: + * + * $query->filterByAttributePostscriptumn('fooValue'); // WHERE attribute_postscriptumn = 'fooValue' + * $query->filterByAttributePostscriptumn('%fooValue%'); // WHERE attribute_postscriptumn LIKE '%fooValue%' + * + * + * @param string $attributePostscriptumn The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributePostscriptumn($attributePostscriptumn = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributePostscriptumn)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributePostscriptumn)) { + $attributePostscriptumn = str_replace('*', '%', $attributePostscriptumn); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $attributePostscriptumn, $comparison); + } + + /** + * Filter the query on the attribute_av_title column + * + * Example usage: + * + * $query->filterByAttributeAvTitle('fooValue'); // WHERE attribute_av_title = 'fooValue' + * $query->filterByAttributeAvTitle('%fooValue%'); // WHERE attribute_av_title LIKE '%fooValue%' + * + * + * @param string $attributeAvTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvTitle($attributeAvTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvTitle)) { + $attributeAvTitle = str_replace('*', '%', $attributeAvTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $attributeAvTitle, $comparison); + } + + /** + * Filter the query on the attribute_av_chapo column + * + * Example usage: + * + * $query->filterByAttributeAvChapo('fooValue'); // WHERE attribute_av_chapo = 'fooValue' + * $query->filterByAttributeAvChapo('%fooValue%'); // WHERE attribute_av_chapo LIKE '%fooValue%' + * + * + * @param string $attributeAvChapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvChapo($attributeAvChapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvChapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvChapo)) { + $attributeAvChapo = str_replace('*', '%', $attributeAvChapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $attributeAvChapo, $comparison); + } + + /** + * Filter the query on the attribute_av_description column + * + * Example usage: + * + * $query->filterByAttributeAvDescription('fooValue'); // WHERE attribute_av_description = 'fooValue' + * $query->filterByAttributeAvDescription('%fooValue%'); // WHERE attribute_av_description LIKE '%fooValue%' + * + * + * @param string $attributeAvDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvDescription($attributeAvDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvDescription)) { + $attributeAvDescription = str_replace('*', '%', $attributeAvDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $attributeAvDescription, $comparison); + } + + /** + * Filter the query on the attribute_av_postscriptum column + * + * Example usage: + * + * $query->filterByAttributeAvPostscriptum('fooValue'); // WHERE attribute_av_postscriptum = 'fooValue' + * $query->filterByAttributeAvPostscriptum('%fooValue%'); // WHERE attribute_av_postscriptum LIKE '%fooValue%' + * + * + * @param string $attributeAvPostscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvPostscriptum($attributeAvPostscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvPostscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvPostscriptum)) { + $attributeAvPostscriptum = str_replace('*', '%', $attributeAvPostscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $attributeAvPostscriptum, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProduct object + * + * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByOrderProduct($orderProduct, $comparison = null) + { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { + return $this + ->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProduct relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProduct'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProduct'); + } + + return $this; + } + + /** + * Use the OrderProduct relation OrderProduct object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query + */ + public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); + } + + /** + * Exclude object from result + * + * @param ChildOrderProductAttributeCombination $orderProductAttributeCombination Object to remove from the list of results + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function prune($orderProductAttributeCombination = null) + { + if ($orderProductAttributeCombination) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $orderProductAttributeCombination->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the order_product_attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderProductAttributeCombinationTableMap::clearInstancePool(); + OrderProductAttributeCombinationTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderProductAttributeCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderProductAttributeCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + OrderProductAttributeCombinationTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderProductAttributeCombinationTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductAttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductAttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductAttributeCombinationTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductAttributeCombinationTableMap::CREATED_AT); + } + +} // OrderProductAttributeCombinationQuery diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php index b007c89e1..f28102dfb 100644 --- a/core/lib/Thelia/Model/Base/OrderProductQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php @@ -24,12 +24,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildOrderProductQuery orderByOrderId($order = Criteria::ASC) Order by the order_id column * @method ChildOrderProductQuery orderByProductRef($order = Criteria::ASC) Order by the product_ref column + * @method ChildOrderProductQuery orderByProductSaleElementsRef($order = Criteria::ASC) Order by the product_sale_elements_ref column * @method ChildOrderProductQuery orderByTitle($order = Criteria::ASC) Order by the title column - * @method ChildOrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildOrderProductQuery orderByChapo($order = Criteria::ASC) Order by the chapo column + * @method ChildOrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column + * @method ChildOrderProductQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column * @method ChildOrderProductQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column * @method ChildOrderProductQuery orderByPrice($order = Criteria::ASC) Order by the price column - * @method ChildOrderProductQuery orderByTax($order = Criteria::ASC) Order by the tax column + * @method ChildOrderProductQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column + * @method ChildOrderProductQuery orderByWasNew($order = Criteria::ASC) Order by the was_new column + * @method ChildOrderProductQuery orderByWasInPromo($order = Criteria::ASC) Order by the was_in_promo column + * @method ChildOrderProductQuery orderByWeight($order = Criteria::ASC) Order by the weight column + * @method ChildOrderProductQuery orderByTaxRuleTitle($order = Criteria::ASC) Order by the tax_rule_title column + * @method ChildOrderProductQuery orderByTaxRuleDescription($order = Criteria::ASC) Order by the tax_rule_description column * @method ChildOrderProductQuery orderByParent($order = Criteria::ASC) Order by the parent column * @method ChildOrderProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildOrderProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -37,12 +44,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery groupById() Group by the id column * @method ChildOrderProductQuery groupByOrderId() Group by the order_id column * @method ChildOrderProductQuery groupByProductRef() Group by the product_ref column + * @method ChildOrderProductQuery groupByProductSaleElementsRef() Group by the product_sale_elements_ref column * @method ChildOrderProductQuery groupByTitle() Group by the title column - * @method ChildOrderProductQuery groupByDescription() Group by the description column * @method ChildOrderProductQuery groupByChapo() Group by the chapo column + * @method ChildOrderProductQuery groupByDescription() Group by the description column + * @method ChildOrderProductQuery groupByPostscriptum() Group by the postscriptum column * @method ChildOrderProductQuery groupByQuantity() Group by the quantity column * @method ChildOrderProductQuery groupByPrice() Group by the price column - * @method ChildOrderProductQuery groupByTax() Group by the tax column + * @method ChildOrderProductQuery groupByPromoPrice() Group by the promo_price column + * @method ChildOrderProductQuery groupByWasNew() Group by the was_new column + * @method ChildOrderProductQuery groupByWasInPromo() Group by the was_in_promo column + * @method ChildOrderProductQuery groupByWeight() Group by the weight column + * @method ChildOrderProductQuery groupByTaxRuleTitle() Group by the tax_rule_title column + * @method ChildOrderProductQuery groupByTaxRuleDescription() Group by the tax_rule_description column * @method ChildOrderProductQuery groupByParent() Group by the parent column * @method ChildOrderProductQuery groupByCreatedAt() Group by the created_at column * @method ChildOrderProductQuery groupByUpdatedAt() Group by the updated_at column @@ -55,9 +69,13 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation * @method ChildOrderProductQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation * - * @method ChildOrderProductQuery leftJoinOrderFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderFeature relation - * @method ChildOrderProductQuery rightJoinOrderFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderFeature relation - * @method ChildOrderProductQuery innerJoinOrderFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderFeature relation + * @method ChildOrderProductQuery leftJoinOrderProductAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductAttributeCombination relation + * @method ChildOrderProductQuery rightJoinOrderProductAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductAttributeCombination relation + * @method ChildOrderProductQuery innerJoinOrderProductAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductAttributeCombination relation + * + * @method ChildOrderProductQuery leftJoinOrderProductTax($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductTax relation + * @method ChildOrderProductQuery rightJoinOrderProductTax($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductTax relation + * @method ChildOrderProductQuery innerJoinOrderProductTax($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductTax relation * * @method ChildOrderProduct findOne(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query * @method ChildOrderProduct findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query, or a new ChildOrderProduct object populated from the query conditions when no match is found @@ -65,12 +83,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProduct findOneById(int $id) Return the first ChildOrderProduct filtered by the id column * @method ChildOrderProduct findOneByOrderId(int $order_id) Return the first ChildOrderProduct filtered by the order_id column * @method ChildOrderProduct findOneByProductRef(string $product_ref) Return the first ChildOrderProduct filtered by the product_ref column + * @method ChildOrderProduct findOneByProductSaleElementsRef(string $product_sale_elements_ref) Return the first ChildOrderProduct filtered by the product_sale_elements_ref column * @method ChildOrderProduct findOneByTitle(string $title) Return the first ChildOrderProduct filtered by the title column - * @method ChildOrderProduct findOneByDescription(string $description) Return the first ChildOrderProduct filtered by the description column * @method ChildOrderProduct findOneByChapo(string $chapo) Return the first ChildOrderProduct filtered by the chapo column + * @method ChildOrderProduct findOneByDescription(string $description) Return the first ChildOrderProduct filtered by the description column + * @method ChildOrderProduct findOneByPostscriptum(string $postscriptum) Return the first ChildOrderProduct filtered by the postscriptum column * @method ChildOrderProduct findOneByQuantity(double $quantity) Return the first ChildOrderProduct filtered by the quantity column * @method ChildOrderProduct findOneByPrice(double $price) Return the first ChildOrderProduct filtered by the price column - * @method ChildOrderProduct findOneByTax(double $tax) Return the first ChildOrderProduct filtered by the tax column + * @method ChildOrderProduct findOneByPromoPrice(string $promo_price) Return the first ChildOrderProduct filtered by the promo_price column + * @method ChildOrderProduct findOneByWasNew(int $was_new) Return the first ChildOrderProduct filtered by the was_new column + * @method ChildOrderProduct findOneByWasInPromo(int $was_in_promo) Return the first ChildOrderProduct filtered by the was_in_promo column + * @method ChildOrderProduct findOneByWeight(string $weight) Return the first ChildOrderProduct filtered by the weight column + * @method ChildOrderProduct findOneByTaxRuleTitle(string $tax_rule_title) Return the first ChildOrderProduct filtered by the tax_rule_title column + * @method ChildOrderProduct findOneByTaxRuleDescription(string $tax_rule_description) Return the first ChildOrderProduct filtered by the tax_rule_description column * @method ChildOrderProduct findOneByParent(int $parent) Return the first ChildOrderProduct filtered by the parent column * @method ChildOrderProduct findOneByCreatedAt(string $created_at) Return the first ChildOrderProduct filtered by the created_at column * @method ChildOrderProduct findOneByUpdatedAt(string $updated_at) Return the first ChildOrderProduct filtered by the updated_at column @@ -78,12 +103,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method array findById(int $id) Return ChildOrderProduct objects filtered by the id column * @method array findByOrderId(int $order_id) Return ChildOrderProduct objects filtered by the order_id column * @method array findByProductRef(string $product_ref) Return ChildOrderProduct objects filtered by the product_ref column + * @method array findByProductSaleElementsRef(string $product_sale_elements_ref) Return ChildOrderProduct objects filtered by the product_sale_elements_ref column * @method array findByTitle(string $title) Return ChildOrderProduct objects filtered by the title column - * @method array findByDescription(string $description) Return ChildOrderProduct objects filtered by the description column * @method array findByChapo(string $chapo) Return ChildOrderProduct objects filtered by the chapo column + * @method array findByDescription(string $description) Return ChildOrderProduct objects filtered by the description column + * @method array findByPostscriptum(string $postscriptum) Return ChildOrderProduct objects filtered by the postscriptum column * @method array findByQuantity(double $quantity) Return ChildOrderProduct objects filtered by the quantity column * @method array findByPrice(double $price) Return ChildOrderProduct objects filtered by the price column - * @method array findByTax(double $tax) Return ChildOrderProduct objects filtered by the tax column + * @method array findByPromoPrice(string $promo_price) Return ChildOrderProduct objects filtered by the promo_price column + * @method array findByWasNew(int $was_new) Return ChildOrderProduct objects filtered by the was_new column + * @method array findByWasInPromo(int $was_in_promo) Return ChildOrderProduct objects filtered by the was_in_promo column + * @method array findByWeight(string $weight) Return ChildOrderProduct objects filtered by the weight column + * @method array findByTaxRuleTitle(string $tax_rule_title) Return ChildOrderProduct objects filtered by the tax_rule_title column + * @method array findByTaxRuleDescription(string $tax_rule_description) Return ChildOrderProduct objects filtered by the tax_rule_description column * @method array findByParent(int $parent) Return ChildOrderProduct objects filtered by the parent column * @method array findByCreatedAt(string $created_at) Return ChildOrderProduct objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildOrderProduct objects filtered by the updated_at column @@ -175,7 +207,7 @@ abstract class OrderProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, TITLE, DESCRIPTION, CHAPO, QUANTITY, PRICE, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; + $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX_RULE_TITLE, TAX_RULE_DESCRIPTION, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -377,6 +409,35 @@ abstract class OrderProductQuery extends ModelCriteria return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison); } + /** + * Filter the query on the product_sale_elements_ref column + * + * Example usage: + * + * $query->filterByProductSaleElementsRef('fooValue'); // WHERE product_sale_elements_ref = 'fooValue' + * $query->filterByProductSaleElementsRef('%fooValue%'); // WHERE product_sale_elements_ref LIKE '%fooValue%' + * + * + * @param string $productSaleElementsRef The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByProductSaleElementsRef($productSaleElementsRef = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($productSaleElementsRef)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $productSaleElementsRef)) { + $productSaleElementsRef = str_replace('*', '%', $productSaleElementsRef); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $productSaleElementsRef, $comparison); + } + /** * Filter the query on the title column * @@ -406,6 +467,35 @@ abstract class OrderProductQuery extends ModelCriteria return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison); } + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); + } + /** * Filter the query on the description column * @@ -436,32 +526,32 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query on the chapo column + * Filter the query on the postscriptum column * * Example usage: * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' * * - * @param string $chapo The value to use as filter. + * @param string $postscriptum The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByChapo($chapo = null, $comparison = null) + public function filterByPostscriptum($postscriptum = null, $comparison = null) { if (null === $comparison) { - if (is_array($chapo)) { + if (is_array($postscriptum)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(OrderProductTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** @@ -547,16 +637,45 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query on the tax column + * Filter the query on the promo_price column * * Example usage: * - * $query->filterByTax(1234); // WHERE tax = 1234 - * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) - * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 + * $query->filterByPromoPrice('fooValue'); // WHERE promo_price = 'fooValue' + * $query->filterByPromoPrice('%fooValue%'); // WHERE promo_price LIKE '%fooValue%' * * - * @param mixed $tax The value to use as filter. + * @param string $promoPrice The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByPromoPrice($promoPrice = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($promoPrice)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $promoPrice)) { + $promoPrice = str_replace('*', '%', $promoPrice); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PROMO_PRICE, $promoPrice, $comparison); + } + + /** + * Filter the query on the was_new column + * + * Example usage: + * + * $query->filterByWasNew(1234); // WHERE was_new = 1234 + * $query->filterByWasNew(array(12, 34)); // WHERE was_new IN (12, 34) + * $query->filterByWasNew(array('min' => 12)); // WHERE was_new > 12 + * + * + * @param mixed $wasNew The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -564,16 +683,16 @@ abstract class OrderProductQuery extends ModelCriteria * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByTax($tax = null, $comparison = null) + public function filterByWasNew($wasNew = null, $comparison = null) { - if (is_array($tax)) { + if (is_array($wasNew)) { $useMinMax = false; - if (isset($tax['min'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL); + if (isset($wasNew['min'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($tax['max'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL); + if (isset($wasNew['max'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -584,7 +703,135 @@ abstract class OrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison); + return $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew, $comparison); + } + + /** + * Filter the query on the was_in_promo column + * + * Example usage: + * + * $query->filterByWasInPromo(1234); // WHERE was_in_promo = 1234 + * $query->filterByWasInPromo(array(12, 34)); // WHERE was_in_promo IN (12, 34) + * $query->filterByWasInPromo(array('min' => 12)); // WHERE was_in_promo > 12 + * + * + * @param mixed $wasInPromo The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWasInPromo($wasInPromo = null, $comparison = null) + { + if (is_array($wasInPromo)) { + $useMinMax = false; + if (isset($wasInPromo['min'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($wasInPromo['max'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo, $comparison); + } + + /** + * Filter the query on the weight column + * + * Example usage: + * + * $query->filterByWeight('fooValue'); // WHERE weight = 'fooValue' + * $query->filterByWeight('%fooValue%'); // WHERE weight LIKE '%fooValue%' + * + * + * @param string $weight The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWeight($weight = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($weight)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $weight)) { + $weight = str_replace('*', '%', $weight); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WEIGHT, $weight, $comparison); + } + + /** + * Filter the query on the tax_rule_title column + * + * Example usage: + * + * $query->filterByTaxRuleTitle('fooValue'); // WHERE tax_rule_title = 'fooValue' + * $query->filterByTaxRuleTitle('%fooValue%'); // WHERE tax_rule_title LIKE '%fooValue%' + * + * + * @param string $taxRuleTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTaxRuleTitle($taxRuleTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($taxRuleTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $taxRuleTitle)) { + $taxRuleTitle = str_replace('*', '%', $taxRuleTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_TITLE, $taxRuleTitle, $comparison); + } + + /** + * Filter the query on the tax_rule_description column + * + * Example usage: + * + * $query->filterByTaxRuleDescription('fooValue'); // WHERE tax_rule_description = 'fooValue' + * $query->filterByTaxRuleDescription('%fooValue%'); // WHERE tax_rule_description LIKE '%fooValue%' + * + * + * @param string $taxRuleDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTaxRuleDescription($taxRuleDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($taxRuleDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $taxRuleDescription)) { + $taxRuleDescription = str_replace('*', '%', $taxRuleDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_DESCRIPTION, $taxRuleDescription, $comparison); } /** @@ -790,40 +1037,40 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\OrderFeature object + * Filter the query by a related \Thelia\Model\OrderProductAttributeCombination object * - * @param \Thelia\Model\OrderFeature|ObjectCollection $orderFeature the related object to use as filter + * @param \Thelia\Model\OrderProductAttributeCombination|ObjectCollection $orderProductAttributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByOrderFeature($orderFeature, $comparison = null) + public function filterByOrderProductAttributeCombination($orderProductAttributeCombination, $comparison = null) { - if ($orderFeature instanceof \Thelia\Model\OrderFeature) { + if ($orderProductAttributeCombination instanceof \Thelia\Model\OrderProductAttributeCombination) { return $this - ->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison); - } elseif ($orderFeature instanceof ObjectCollection) { + ->addUsingAlias(OrderProductTableMap::ID, $orderProductAttributeCombination->getOrderProductId(), $comparison); + } elseif ($orderProductAttributeCombination instanceof ObjectCollection) { return $this - ->useOrderFeatureQuery() - ->filterByPrimaryKeys($orderFeature->getPrimaryKeys()) + ->useOrderProductAttributeCombinationQuery() + ->filterByPrimaryKeys($orderProductAttributeCombination->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection'); + throw new PropelException('filterByOrderProductAttributeCombination() only accepts arguments of type \Thelia\Model\OrderProductAttributeCombination or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderFeature relation + * Adds a JOIN clause to the query using the OrderProductAttributeCombination relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinOrderProductAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderFeature'); + $relationMap = $tableMap->getRelation('OrderProductAttributeCombination'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -838,14 +1085,14 @@ abstract class OrderProductQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderFeature'); + $this->addJoinObject($join, 'OrderProductAttributeCombination'); } return $this; } /** - * Use the OrderFeature relation OrderFeature object + * Use the OrderProductAttributeCombination relation OrderProductAttributeCombination object * * @see useQuery() * @@ -853,13 +1100,86 @@ abstract class OrderProductQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\OrderProductAttributeCombinationQuery A secondary query class using the current class as primary query */ - public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useOrderProductAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery'); + ->joinOrderProductAttributeCombination($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProductAttributeCombination', '\Thelia\Model\OrderProductAttributeCombinationQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProductTax object + * + * @param \Thelia\Model\OrderProductTax|ObjectCollection $orderProductTax the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByOrderProductTax($orderProductTax, $comparison = null) + { + if ($orderProductTax instanceof \Thelia\Model\OrderProductTax) { + return $this + ->addUsingAlias(OrderProductTableMap::ID, $orderProductTax->getOrderProductId(), $comparison); + } elseif ($orderProductTax instanceof ObjectCollection) { + return $this + ->useOrderProductTaxQuery() + ->filterByPrimaryKeys($orderProductTax->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderProductTax() only accepts arguments of type \Thelia\Model\OrderProductTax or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProductTax relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function joinOrderProductTax($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProductTax'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProductTax'); + } + + return $this; + } + + /** + * Use the OrderProductTax relation OrderProductTax object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductTaxQuery A secondary query class using the current class as primary query + */ + public function useOrderProductTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProductTax($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProductTax', '\Thelia\Model\OrderProductTaxQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProductTax.php b/core/lib/Thelia/Model/Base/OrderProductTax.php new file mode 100644 index 000000000..544755ff4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductTax.php @@ -0,0 +1,1534 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderProductTax instance. If + * obj is an instance of OrderProductTax, delegates to + * equals(OrderProductTax). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderProductTax The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderProductTax The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [order_product_id] column value. + * + * @return int + */ + public function getOrderProductId() + { + + return $this->order_product_id; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [amount] column value. + * + * @return double + */ + public function getAmount() + { + + return $this->amount; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setOrderProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_product_id !== $v) { + $this->order_product_id = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::ORDER_PRODUCT_ID; + } + + if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { + $this->aOrderProduct = null; + } + + + return $this; + } // setOrderProductId() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [amount] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setAmount($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->amount !== $v) { + $this->amount = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::AMOUNT; + } + + + return $this; + } // setAmount() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderProductTaxTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderProductTaxTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductTaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductTaxTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTaxTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTaxTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTaxTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->amount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = OrderProductTaxTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderProductTax object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { + $this->aOrderProduct = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderProductTaxQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrderProduct = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderProductTax::setDeleted() + * @see OrderProductTax::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderProductTaxQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + OrderProductTaxTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aOrderProduct !== null) { + if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { + $affectedRows += $this->aOrderProduct->save($con); + } + $this->setOrderProduct($this->aOrderProduct); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderProductTaxTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductTaxTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderProductTaxTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::ORDER_PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'AMOUNT'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO order_product_tax (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'ORDER_PRODUCT_ID': + $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'AMOUNT': + $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductTaxTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getOrderProductId(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getAmount(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderProductTax'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderProductTax'][$this->getPrimaryKey()] = true; + $keys = OrderProductTaxTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getOrderProductId(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getAmount(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aOrderProduct) { + $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductTaxTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setOrderProductId($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setAmount($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = OrderProductTaxTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAmount($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(OrderProductTaxTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderProductTaxTableMap::ID)) $criteria->add(OrderProductTaxTableMap::ID, $this->id); + if ($this->isColumnModified(OrderProductTaxTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $this->order_product_id); + if ($this->isColumnModified(OrderProductTaxTableMap::TITLE)) $criteria->add(OrderProductTaxTableMap::TITLE, $this->title); + if ($this->isColumnModified(OrderProductTaxTableMap::DESCRIPTION)) $criteria->add(OrderProductTaxTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderProductTaxTableMap::AMOUNT)) $criteria->add(OrderProductTaxTableMap::AMOUNT, $this->amount); + if ($this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) $criteria->add(OrderProductTaxTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) $criteria->add(OrderProductTaxTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(OrderProductTaxTableMap::DATABASE_NAME); + $criteria->add(OrderProductTaxTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\OrderProductTax (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setOrderProductId($this->getOrderProductId()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setAmount($this->getAmount()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderProductTax Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildOrderProduct object. + * + * @param ChildOrderProduct $v + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + * @throws PropelException + */ + public function setOrderProduct(ChildOrderProduct $v = null) + { + if ($v === null) { + $this->setOrderProductId(NULL); + } else { + $this->setOrderProductId($v->getId()); + } + + $this->aOrderProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildOrderProduct object, it will not be re-added. + if ($v !== null) { + $v->addOrderProductTax($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrderProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderProduct The associated ChildOrderProduct object. + * @throws PropelException + */ + public function getOrderProduct(ConnectionInterface $con = null) + { + if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aOrderProduct->addOrderProductTaxes($this); + */ + } + + return $this->aOrderProduct; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->order_product_id = null; + $this->title = null; + $this->description = null; + $this->amount = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrderProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderProductTaxTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildOrderProductTax The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderProductTaxTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php b/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php new file mode 100644 index 000000000..d37c2c501 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php @@ -0,0 +1,744 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderProductTax|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderProductTaxTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductTax A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_PRODUCT_ID, TITLE, DESCRIPTION, AMOUNT, CREATED_AT, UPDATED_AT FROM order_product_tax WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderProductTax(); + $obj->hydrate($row); + OrderProductTaxTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductTax|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(OrderProductTaxTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(OrderProductTaxTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_product_id column + * + * Example usage: + * + * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 + * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 + * + * + * @see filterByOrderProduct() + * + * @param mixed $orderProductId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByOrderProductId($orderProductId = null, $comparison = null) + { + if (is_array($orderProductId)) { + $useMinMax = false; + if (isset($orderProductId['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderProductId['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the amount column + * + * Example usage: + * + * $query->filterByAmount(1234); // WHERE amount = 1234 + * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) + * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 + * + * + * @param mixed $amount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByAmount($amount = null, $comparison = null) + { + if (is_array($amount)) { + $useMinMax = false; + if (isset($amount['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($amount['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProduct object + * + * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByOrderProduct($orderProduct, $comparison = null) + { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { + return $this + ->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProduct relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProduct'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProduct'); + } + + return $this; + } + + /** + * Use the OrderProduct relation OrderProduct object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query + */ + public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); + } + + /** + * Exclude object from result + * + * @param ChildOrderProductTax $orderProductTax Object to remove from the list of results + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function prune($orderProductTax = null) + { + if ($orderProductTax) { + $this->addUsingAlias(OrderProductTaxTableMap::ID, $orderProductTax->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the order_product_tax table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderProductTaxTableMap::clearInstancePool(); + OrderProductTaxTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderProductTax or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderProductTax object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderProductTaxTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + OrderProductTaxTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderProductTaxTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTaxTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTaxTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTaxTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTaxTableMap::CREATED_AT); + } + +} // OrderProductTaxQuery diff --git a/core/lib/Thelia/Model/Base/OrderQuery.php b/core/lib/Thelia/Model/Base/OrderQuery.php index bdff793a8..592864f1f 100644 --- a/core/lib/Thelia/Model/Base/OrderQuery.php +++ b/core/lib/Thelia/Model/Base/OrderQuery.php @@ -24,38 +24,38 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildOrderQuery orderByRef($order = Criteria::ASC) Order by the ref column * @method ChildOrderQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column - * @method ChildOrderQuery orderByAddressInvoice($order = Criteria::ASC) Order by the address_invoice column - * @method ChildOrderQuery orderByAddressDelivery($order = Criteria::ASC) Order by the address_delivery column + * @method ChildOrderQuery orderByInvoiceOrderAddressId($order = Criteria::ASC) Order by the invoice_order_address_id column + * @method ChildOrderQuery orderByDeliveryOrderAddressId($order = Criteria::ASC) Order by the delivery_order_address_id column * @method ChildOrderQuery orderByInvoiceDate($order = Criteria::ASC) Order by the invoice_date column * @method ChildOrderQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column * @method ChildOrderQuery orderByCurrencyRate($order = Criteria::ASC) Order by the currency_rate column - * @method ChildOrderQuery orderByTransaction($order = Criteria::ASC) Order by the transaction column - * @method ChildOrderQuery orderByDeliveryNum($order = Criteria::ASC) Order by the delivery_num column - * @method ChildOrderQuery orderByInvoice($order = Criteria::ASC) Order by the invoice column + * @method ChildOrderQuery orderByTransactionRef($order = Criteria::ASC) Order by the transaction_ref column + * @method ChildOrderQuery orderByDeliveryRef($order = Criteria::ASC) Order by the delivery_ref column + * @method ChildOrderQuery orderByInvoiceRef($order = Criteria::ASC) Order by the invoice_ref column * @method ChildOrderQuery orderByPostage($order = Criteria::ASC) Order by the postage column - * @method ChildOrderQuery orderByPayment($order = Criteria::ASC) Order by the payment column - * @method ChildOrderQuery orderByCarrier($order = Criteria::ASC) Order by the carrier column + * @method ChildOrderQuery orderByPaymentModuleId($order = Criteria::ASC) Order by the payment_module_id column + * @method ChildOrderQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column * @method ChildOrderQuery orderByStatusId($order = Criteria::ASC) Order by the status_id column - * @method ChildOrderQuery orderByLang($order = Criteria::ASC) Order by the lang column + * @method ChildOrderQuery orderByLangId($order = Criteria::ASC) Order by the lang_id column * @method ChildOrderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildOrderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildOrderQuery groupById() Group by the id column * @method ChildOrderQuery groupByRef() Group by the ref column * @method ChildOrderQuery groupByCustomerId() Group by the customer_id column - * @method ChildOrderQuery groupByAddressInvoice() Group by the address_invoice column - * @method ChildOrderQuery groupByAddressDelivery() Group by the address_delivery column + * @method ChildOrderQuery groupByInvoiceOrderAddressId() Group by the invoice_order_address_id column + * @method ChildOrderQuery groupByDeliveryOrderAddressId() Group by the delivery_order_address_id column * @method ChildOrderQuery groupByInvoiceDate() Group by the invoice_date column * @method ChildOrderQuery groupByCurrencyId() Group by the currency_id column * @method ChildOrderQuery groupByCurrencyRate() Group by the currency_rate column - * @method ChildOrderQuery groupByTransaction() Group by the transaction column - * @method ChildOrderQuery groupByDeliveryNum() Group by the delivery_num column - * @method ChildOrderQuery groupByInvoice() Group by the invoice column + * @method ChildOrderQuery groupByTransactionRef() Group by the transaction_ref column + * @method ChildOrderQuery groupByDeliveryRef() Group by the delivery_ref column + * @method ChildOrderQuery groupByInvoiceRef() Group by the invoice_ref column * @method ChildOrderQuery groupByPostage() Group by the postage column - * @method ChildOrderQuery groupByPayment() Group by the payment column - * @method ChildOrderQuery groupByCarrier() Group by the carrier column + * @method ChildOrderQuery groupByPaymentModuleId() Group by the payment_module_id column + * @method ChildOrderQuery groupByDeliveryModuleId() Group by the delivery_module_id column * @method ChildOrderQuery groupByStatusId() Group by the status_id column - * @method ChildOrderQuery groupByLang() Group by the lang column + * @method ChildOrderQuery groupByLangId() Group by the lang_id column * @method ChildOrderQuery groupByCreatedAt() Group by the created_at column * @method ChildOrderQuery groupByUpdatedAt() Group by the updated_at column * @@ -71,18 +71,30 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation * @method ChildOrderQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation * - * @method ChildOrderQuery leftJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation - * @method ChildOrderQuery rightJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation - * @method ChildOrderQuery innerJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation + * @method ChildOrderQuery leftJoinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation + * @method ChildOrderQuery rightJoinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation + * @method ChildOrderQuery innerJoinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation * - * @method ChildOrderQuery leftJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation - * @method ChildOrderQuery rightJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation - * @method ChildOrderQuery innerJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation + * @method ChildOrderQuery leftJoinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation + * @method ChildOrderQuery rightJoinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation + * @method ChildOrderQuery innerJoinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation * * @method ChildOrderQuery leftJoinOrderStatus($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderStatus relation * @method ChildOrderQuery rightJoinOrderStatus($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderStatus relation * @method ChildOrderQuery innerJoinOrderStatus($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderStatus relation * + * @method ChildOrderQuery leftJoinModuleRelatedByPaymentModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * @method ChildOrderQuery rightJoinModuleRelatedByPaymentModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * @method ChildOrderQuery innerJoinModuleRelatedByPaymentModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * + * @method ChildOrderQuery leftJoinModuleRelatedByDeliveryModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * @method ChildOrderQuery rightJoinModuleRelatedByDeliveryModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * @method ChildOrderQuery innerJoinModuleRelatedByDeliveryModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * + * @method ChildOrderQuery leftJoinLang($relationAlias = null) Adds a LEFT JOIN clause to the query using the Lang relation + * @method ChildOrderQuery rightJoinLang($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Lang relation + * @method ChildOrderQuery innerJoinLang($relationAlias = null) Adds a INNER JOIN clause to the query using the Lang relation + * * @method ChildOrderQuery leftJoinOrderProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProduct relation * @method ChildOrderQuery rightJoinOrderProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProduct relation * @method ChildOrderQuery innerJoinOrderProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProduct relation @@ -97,38 +109,38 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrder findOneById(int $id) Return the first ChildOrder filtered by the id column * @method ChildOrder findOneByRef(string $ref) Return the first ChildOrder filtered by the ref column * @method ChildOrder findOneByCustomerId(int $customer_id) Return the first ChildOrder filtered by the customer_id column - * @method ChildOrder findOneByAddressInvoice(int $address_invoice) Return the first ChildOrder filtered by the address_invoice column - * @method ChildOrder findOneByAddressDelivery(int $address_delivery) Return the first ChildOrder filtered by the address_delivery column + * @method ChildOrder findOneByInvoiceOrderAddressId(int $invoice_order_address_id) Return the first ChildOrder filtered by the invoice_order_address_id column + * @method ChildOrder findOneByDeliveryOrderAddressId(int $delivery_order_address_id) Return the first ChildOrder filtered by the delivery_order_address_id column * @method ChildOrder findOneByInvoiceDate(string $invoice_date) Return the first ChildOrder filtered by the invoice_date column * @method ChildOrder findOneByCurrencyId(int $currency_id) Return the first ChildOrder filtered by the currency_id column * @method ChildOrder findOneByCurrencyRate(double $currency_rate) Return the first ChildOrder filtered by the currency_rate column - * @method ChildOrder findOneByTransaction(string $transaction) Return the first ChildOrder filtered by the transaction column - * @method ChildOrder findOneByDeliveryNum(string $delivery_num) Return the first ChildOrder filtered by the delivery_num column - * @method ChildOrder findOneByInvoice(string $invoice) Return the first ChildOrder filtered by the invoice column + * @method ChildOrder findOneByTransactionRef(string $transaction_ref) Return the first ChildOrder filtered by the transaction_ref column + * @method ChildOrder findOneByDeliveryRef(string $delivery_ref) Return the first ChildOrder filtered by the delivery_ref column + * @method ChildOrder findOneByInvoiceRef(string $invoice_ref) Return the first ChildOrder filtered by the invoice_ref column * @method ChildOrder findOneByPostage(double $postage) Return the first ChildOrder filtered by the postage column - * @method ChildOrder findOneByPayment(string $payment) Return the first ChildOrder filtered by the payment column - * @method ChildOrder findOneByCarrier(string $carrier) Return the first ChildOrder filtered by the carrier column + * @method ChildOrder findOneByPaymentModuleId(int $payment_module_id) Return the first ChildOrder filtered by the payment_module_id column + * @method ChildOrder findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildOrder filtered by the delivery_module_id column * @method ChildOrder findOneByStatusId(int $status_id) Return the first ChildOrder filtered by the status_id column - * @method ChildOrder findOneByLang(string $lang) Return the first ChildOrder filtered by the lang column + * @method ChildOrder findOneByLangId(int $lang_id) Return the first ChildOrder filtered by the lang_id column * @method ChildOrder findOneByCreatedAt(string $created_at) Return the first ChildOrder filtered by the created_at column * @method ChildOrder findOneByUpdatedAt(string $updated_at) Return the first ChildOrder filtered by the updated_at column * * @method array findById(int $id) Return ChildOrder objects filtered by the id column * @method array findByRef(string $ref) Return ChildOrder objects filtered by the ref column * @method array findByCustomerId(int $customer_id) Return ChildOrder objects filtered by the customer_id column - * @method array findByAddressInvoice(int $address_invoice) Return ChildOrder objects filtered by the address_invoice column - * @method array findByAddressDelivery(int $address_delivery) Return ChildOrder objects filtered by the address_delivery column + * @method array findByInvoiceOrderAddressId(int $invoice_order_address_id) Return ChildOrder objects filtered by the invoice_order_address_id column + * @method array findByDeliveryOrderAddressId(int $delivery_order_address_id) Return ChildOrder objects filtered by the delivery_order_address_id column * @method array findByInvoiceDate(string $invoice_date) Return ChildOrder objects filtered by the invoice_date column * @method array findByCurrencyId(int $currency_id) Return ChildOrder objects filtered by the currency_id column * @method array findByCurrencyRate(double $currency_rate) Return ChildOrder objects filtered by the currency_rate column - * @method array findByTransaction(string $transaction) Return ChildOrder objects filtered by the transaction column - * @method array findByDeliveryNum(string $delivery_num) Return ChildOrder objects filtered by the delivery_num column - * @method array findByInvoice(string $invoice) Return ChildOrder objects filtered by the invoice column + * @method array findByTransactionRef(string $transaction_ref) Return ChildOrder objects filtered by the transaction_ref column + * @method array findByDeliveryRef(string $delivery_ref) Return ChildOrder objects filtered by the delivery_ref column + * @method array findByInvoiceRef(string $invoice_ref) Return ChildOrder objects filtered by the invoice_ref column * @method array findByPostage(double $postage) Return ChildOrder objects filtered by the postage column - * @method array findByPayment(string $payment) Return ChildOrder objects filtered by the payment column - * @method array findByCarrier(string $carrier) Return ChildOrder objects filtered by the carrier column + * @method array findByPaymentModuleId(int $payment_module_id) Return ChildOrder objects filtered by the payment_module_id column + * @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildOrder objects filtered by the delivery_module_id column * @method array findByStatusId(int $status_id) Return ChildOrder objects filtered by the status_id column - * @method array findByLang(string $lang) Return ChildOrder objects filtered by the lang column + * @method array findByLangId(int $lang_id) Return ChildOrder objects filtered by the lang_id column * @method array findByCreatedAt(string $created_at) Return ChildOrder objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildOrder objects filtered by the updated_at column * @@ -219,7 +231,7 @@ abstract class OrderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, CUSTOMER_ID, ADDRESS_INVOICE, ADDRESS_DELIVERY, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION, DELIVERY_NUM, INVOICE, POSTAGE, PAYMENT, CARRIER, STATUS_ID, LANG, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0'; + $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -422,18 +434,18 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the address_invoice column + * Filter the query on the invoice_order_address_id column * * Example usage: * - * $query->filterByAddressInvoice(1234); // WHERE address_invoice = 1234 - * $query->filterByAddressInvoice(array(12, 34)); // WHERE address_invoice IN (12, 34) - * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12 + * $query->filterByInvoiceOrderAddressId(1234); // WHERE invoice_order_address_id = 1234 + * $query->filterByInvoiceOrderAddressId(array(12, 34)); // WHERE invoice_order_address_id IN (12, 34) + * $query->filterByInvoiceOrderAddressId(array('min' => 12)); // WHERE invoice_order_address_id > 12 * * - * @see filterByOrderAddressRelatedByAddressInvoice() + * @see filterByOrderAddressRelatedByInvoiceOrderAddressId() * - * @param mixed $addressInvoice The value to use as filter. + * @param mixed $invoiceOrderAddressId The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -441,16 +453,16 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByAddressInvoice($addressInvoice = null, $comparison = null) + public function filterByInvoiceOrderAddressId($invoiceOrderAddressId = null, $comparison = null) { - if (is_array($addressInvoice)) { + if (is_array($invoiceOrderAddressId)) { $useMinMax = false; - if (isset($addressInvoice['min'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['min'], Criteria::GREATER_EQUAL); + if (isset($invoiceOrderAddressId['min'])) { + $this->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $invoiceOrderAddressId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($addressInvoice['max'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL); + if (isset($invoiceOrderAddressId['max'])) { + $this->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $invoiceOrderAddressId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -461,22 +473,22 @@ abstract class OrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice, $comparison); + return $this->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $invoiceOrderAddressId, $comparison); } /** - * Filter the query on the address_delivery column + * Filter the query on the delivery_order_address_id column * * Example usage: * - * $query->filterByAddressDelivery(1234); // WHERE address_delivery = 1234 - * $query->filterByAddressDelivery(array(12, 34)); // WHERE address_delivery IN (12, 34) - * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12 + * $query->filterByDeliveryOrderAddressId(1234); // WHERE delivery_order_address_id = 1234 + * $query->filterByDeliveryOrderAddressId(array(12, 34)); // WHERE delivery_order_address_id IN (12, 34) + * $query->filterByDeliveryOrderAddressId(array('min' => 12)); // WHERE delivery_order_address_id > 12 * * - * @see filterByOrderAddressRelatedByAddressDelivery() + * @see filterByOrderAddressRelatedByDeliveryOrderAddressId() * - * @param mixed $addressDelivery The value to use as filter. + * @param mixed $deliveryOrderAddressId The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -484,16 +496,16 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByAddressDelivery($addressDelivery = null, $comparison = null) + public function filterByDeliveryOrderAddressId($deliveryOrderAddressId = null, $comparison = null) { - if (is_array($addressDelivery)) { + if (is_array($deliveryOrderAddressId)) { $useMinMax = false; - if (isset($addressDelivery['min'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['min'], Criteria::GREATER_EQUAL); + if (isset($deliveryOrderAddressId['min'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $deliveryOrderAddressId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($addressDelivery['max'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL); + if (isset($deliveryOrderAddressId['max'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $deliveryOrderAddressId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -504,7 +516,7 @@ abstract class OrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $deliveryOrderAddressId, $comparison); } /** @@ -635,90 +647,90 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the transaction column + * Filter the query on the transaction_ref column * * Example usage: * - * $query->filterByTransaction('fooValue'); // WHERE transaction = 'fooValue' - * $query->filterByTransaction('%fooValue%'); // WHERE transaction LIKE '%fooValue%' + * $query->filterByTransactionRef('fooValue'); // WHERE transaction_ref = 'fooValue' + * $query->filterByTransactionRef('%fooValue%'); // WHERE transaction_ref LIKE '%fooValue%' * * - * @param string $transaction The value to use as filter. + * @param string $transactionRef The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByTransaction($transaction = null, $comparison = null) + public function filterByTransactionRef($transactionRef = null, $comparison = null) { if (null === $comparison) { - if (is_array($transaction)) { + if (is_array($transactionRef)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $transaction)) { - $transaction = str_replace('*', '%', $transaction); + } elseif (preg_match('/[\%\*]/', $transactionRef)) { + $transactionRef = str_replace('*', '%', $transactionRef); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::TRANSACTION, $transaction, $comparison); + return $this->addUsingAlias(OrderTableMap::TRANSACTION_REF, $transactionRef, $comparison); } /** - * Filter the query on the delivery_num column + * Filter the query on the delivery_ref column * * Example usage: * - * $query->filterByDeliveryNum('fooValue'); // WHERE delivery_num = 'fooValue' - * $query->filterByDeliveryNum('%fooValue%'); // WHERE delivery_num LIKE '%fooValue%' + * $query->filterByDeliveryRef('fooValue'); // WHERE delivery_ref = 'fooValue' + * $query->filterByDeliveryRef('%fooValue%'); // WHERE delivery_ref LIKE '%fooValue%' * * - * @param string $deliveryNum The value to use as filter. + * @param string $deliveryRef The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByDeliveryNum($deliveryNum = null, $comparison = null) + public function filterByDeliveryRef($deliveryRef = null, $comparison = null) { if (null === $comparison) { - if (is_array($deliveryNum)) { + if (is_array($deliveryRef)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $deliveryNum)) { - $deliveryNum = str_replace('*', '%', $deliveryNum); + } elseif (preg_match('/[\%\*]/', $deliveryRef)) { + $deliveryRef = str_replace('*', '%', $deliveryRef); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::DELIVERY_NUM, $deliveryNum, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_REF, $deliveryRef, $comparison); } /** - * Filter the query on the invoice column + * Filter the query on the invoice_ref column * * Example usage: * - * $query->filterByInvoice('fooValue'); // WHERE invoice = 'fooValue' - * $query->filterByInvoice('%fooValue%'); // WHERE invoice LIKE '%fooValue%' + * $query->filterByInvoiceRef('fooValue'); // WHERE invoice_ref = 'fooValue' + * $query->filterByInvoiceRef('%fooValue%'); // WHERE invoice_ref LIKE '%fooValue%' * * - * @param string $invoice The value to use as filter. + * @param string $invoiceRef The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByInvoice($invoice = null, $comparison = null) + public function filterByInvoiceRef($invoiceRef = null, $comparison = null) { if (null === $comparison) { - if (is_array($invoice)) { + if (is_array($invoiceRef)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $invoice)) { - $invoice = str_replace('*', '%', $invoice); + } elseif (preg_match('/[\%\*]/', $invoiceRef)) { + $invoiceRef = str_replace('*', '%', $invoiceRef); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::INVOICE, $invoice, $comparison); + return $this->addUsingAlias(OrderTableMap::INVOICE_REF, $invoiceRef, $comparison); } /** @@ -763,61 +775,89 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the payment column + * Filter the query on the payment_module_id column * * Example usage: * - * $query->filterByPayment('fooValue'); // WHERE payment = 'fooValue' - * $query->filterByPayment('%fooValue%'); // WHERE payment LIKE '%fooValue%' + * $query->filterByPaymentModuleId(1234); // WHERE payment_module_id = 1234 + * $query->filterByPaymentModuleId(array(12, 34)); // WHERE payment_module_id IN (12, 34) + * $query->filterByPaymentModuleId(array('min' => 12)); // WHERE payment_module_id > 12 * * - * @param string $payment The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModuleRelatedByPaymentModuleId() + * + * @param mixed $paymentModuleId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByPayment($payment = null, $comparison = null) + public function filterByPaymentModuleId($paymentModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($payment)) { + if (is_array($paymentModuleId)) { + $useMinMax = false; + if (isset($paymentModuleId['min'])) { + $this->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $paymentModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($paymentModuleId['max'])) { + $this->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $paymentModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $payment)) { - $payment = str_replace('*', '%', $payment); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::PAYMENT, $payment, $comparison); + return $this->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $paymentModuleId, $comparison); } /** - * Filter the query on the carrier column + * Filter the query on the delivery_module_id column * * Example usage: * - * $query->filterByCarrier('fooValue'); // WHERE carrier = 'fooValue' - * $query->filterByCarrier('%fooValue%'); // WHERE carrier LIKE '%fooValue%' + * $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234 + * $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34) + * $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12 * * - * @param string $carrier The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModuleRelatedByDeliveryModuleId() + * + * @param mixed $deliveryModuleId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByCarrier($carrier = null, $comparison = null) + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($carrier)) { + if (is_array($deliveryModuleId)) { + $useMinMax = false; + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $carrier)) { - $carrier = str_replace('*', '%', $carrier); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::CARRIER, $carrier, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); } /** @@ -864,32 +904,46 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the lang column + * Filter the query on the lang_id column * * Example usage: * - * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue' - * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%' + * $query->filterByLangId(1234); // WHERE lang_id = 1234 + * $query->filterByLangId(array(12, 34)); // WHERE lang_id IN (12, 34) + * $query->filterByLangId(array('min' => 12)); // WHERE lang_id > 12 * * - * @param string $lang The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByLang() + * + * @param mixed $langId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByLang($lang = null, $comparison = null) + public function filterByLangId($langId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($lang)) { + if (is_array($langId)) { + $useMinMax = false; + if (isset($langId['min'])) { + $this->addUsingAlias(OrderTableMap::LANG_ID, $langId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($langId['max'])) { + $this->addUsingAlias(OrderTableMap::LANG_ID, $langId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lang)) { - $lang = str_replace('*', '%', $lang); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::LANG, $lang, $comparison); + return $this->addUsingAlias(OrderTableMap::LANG_ID, $langId, $comparison); } /** @@ -1011,7 +1065,7 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinCurrency($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Currency'); @@ -1046,7 +1100,7 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\CurrencyQuery A secondary query class using the current class as primary query */ - public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCurrency($relationAlias, $joinType) @@ -1136,35 +1190,35 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null) + public function filterByOrderAddressRelatedByInvoiceOrderAddressId($orderAddress, $comparison = null) { if ($orderAddress instanceof \Thelia\Model\OrderAddress) { return $this - ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->getId(), $comparison); + ->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $orderAddress->getId(), $comparison); } elseif ($orderAddress instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); + throw new PropelException('filterByOrderAddressRelatedByInvoiceOrderAddressId() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation + * Adds a JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressInvoice'); + $relationMap = $tableMap->getRelation('OrderAddressRelatedByInvoiceOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1179,14 +1233,14 @@ abstract class OrderQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderAddressRelatedByAddressInvoice'); + $this->addJoinObject($join, 'OrderAddressRelatedByInvoiceOrderAddressId'); } return $this; } /** - * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress object + * Use the OrderAddressRelatedByInvoiceOrderAddressId relation OrderAddress object * * @see useQuery() * @@ -1196,11 +1250,11 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query */ - public function useOrderAddressRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderAddressRelatedByInvoiceOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderAddressRelatedByAddressInvoice($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressInvoice', '\Thelia\Model\OrderAddressQuery'); + ->joinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByInvoiceOrderAddressId', '\Thelia\Model\OrderAddressQuery'); } /** @@ -1211,35 +1265,35 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null) + public function filterByOrderAddressRelatedByDeliveryOrderAddressId($orderAddress, $comparison = null) { if ($orderAddress instanceof \Thelia\Model\OrderAddress) { return $this - ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison); + ->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $orderAddress->getId(), $comparison); } elseif ($orderAddress instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); + throw new PropelException('filterByOrderAddressRelatedByDeliveryOrderAddressId() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation + * Adds a JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressDelivery'); + $relationMap = $tableMap->getRelation('OrderAddressRelatedByDeliveryOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1254,14 +1308,14 @@ abstract class OrderQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderAddressRelatedByAddressDelivery'); + $this->addJoinObject($join, 'OrderAddressRelatedByDeliveryOrderAddressId'); } return $this; } /** - * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress object + * Use the OrderAddressRelatedByDeliveryOrderAddressId relation OrderAddress object * * @see useQuery() * @@ -1271,11 +1325,11 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query */ - public function useOrderAddressRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderAddressRelatedByDeliveryOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderAddressRelatedByAddressDelivery($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressDelivery', '\Thelia\Model\OrderAddressQuery'); + ->joinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByDeliveryOrderAddressId', '\Thelia\Model\OrderAddressQuery'); } /** @@ -1311,7 +1365,7 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderStatus($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('OrderStatus'); @@ -1346,13 +1400,238 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query */ - public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinOrderStatus($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery'); } + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function filterByModuleRelatedByPaymentModuleId($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleRelatedByPaymentModuleId() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function joinModuleRelatedByPaymentModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleRelatedByPaymentModuleId'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ModuleRelatedByPaymentModuleId'); + } + + return $this; + } + + /** + * Use the ModuleRelatedByPaymentModuleId relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleRelatedByPaymentModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleRelatedByPaymentModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleRelatedByPaymentModuleId', '\Thelia\Model\ModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function filterByModuleRelatedByDeliveryModuleId($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleRelatedByDeliveryModuleId() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function joinModuleRelatedByDeliveryModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleRelatedByDeliveryModuleId'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ModuleRelatedByDeliveryModuleId'); + } + + return $this; + } + + /** + * Use the ModuleRelatedByDeliveryModuleId relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleRelatedByDeliveryModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleRelatedByDeliveryModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleRelatedByDeliveryModuleId', '\Thelia\Model\ModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Lang object + * + * @param \Thelia\Model\Lang|ObjectCollection $lang The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function filterByLang($lang, $comparison = null) + { + if ($lang instanceof \Thelia\Model\Lang) { + return $this + ->addUsingAlias(OrderTableMap::LANG_ID, $lang->getId(), $comparison); + } elseif ($lang instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderTableMap::LANG_ID, $lang->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByLang() only accepts arguments of type \Thelia\Model\Lang or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Lang relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function joinLang($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Lang'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Lang'); + } + + return $this; + } + + /** + * Use the Lang relation Lang object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\LangQuery A secondary query class using the current class as primary query + */ + public function useLangQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinLang($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Lang', '\Thelia\Model\LangQuery'); + } + /** * Filter the query by a related \Thelia\Model\OrderProduct object * diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index d249b4865..5771072f2 100644 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -791,10 +791,9 @@ abstract class OrderStatus implements ActiveRecordInterface if ($this->ordersScheduledForDeletion !== null) { if (!$this->ordersScheduledForDeletion->isEmpty()) { - foreach ($this->ordersScheduledForDeletion as $order) { - // need to save related object because we set the relation to null - $order->save($con); - } + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->ordersScheduledForDeletion = null; } } @@ -1439,7 +1438,7 @@ abstract class OrderStatus implements ActiveRecordInterface $this->ordersScheduledForDeletion = clone $this->collOrders; $this->ordersScheduledForDeletion->clear(); } - $this->ordersScheduledForDeletion[]= $order; + $this->ordersScheduledForDeletion[]= clone $order; $order->setOrderStatus(null); } @@ -1513,10 +1512,10 @@ abstract class OrderStatus implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -1538,10 +1537,85 @@ abstract class OrderStatus implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderStatus is new, it will return + * an empty collection; or if this OrderStatus has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderStatus. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderStatus is new, it will return + * an empty collection; or if this OrderStatus has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderStatus. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderStatus is new, it will return + * an empty collection; or if this OrderStatus has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderStatus. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); return $this->getOrders($query, $con); } diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php index 908efd6b6..7050b4a5a 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusQuery.php +++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php @@ -420,7 +420,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Order'); @@ -455,7 +455,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinOrder($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index f7457d47b..9ec203fec 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -43,6 +43,8 @@ use Thelia\Model\ProductVersion as ChildProductVersion; use Thelia\Model\ProductVersionQuery as ChildProductVersionQuery; use Thelia\Model\TaxRule as ChildTaxRule; use Thelia\Model\TaxRuleQuery as ChildTaxRuleQuery; +use Thelia\Model\Template as ChildTemplate; +use Thelia\Model\TemplateQuery as ChildTemplateQuery; use Thelia\Model\Map\ProductTableMap; use Thelia\Model\Map\ProductVersionTableMap; @@ -111,6 +113,12 @@ abstract class Product implements ActiveRecordInterface */ protected $position; + /** + * The value for the template_id field. + * @var int + */ + protected $template_id; + /** * The value for the created_at field. * @var string @@ -147,6 +155,11 @@ abstract class Product implements ActiveRecordInterface */ protected $aTaxRule; + /** + * @var Template + */ + protected $aTemplate; + /** * @var ObjectCollection|ChildProductCategory[] Collection to store aggregation of ChildProductCategory objects. */ @@ -665,6 +678,17 @@ abstract class Product implements ActiveRecordInterface return $this->position; } + /** + * Get the [template_id] column value. + * + * @return int + */ + public function getTemplateId() + { + + return $this->template_id; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -856,6 +880,31 @@ abstract class Product implements ActiveRecordInterface return $this; } // setPosition() + /** + * Set the value of [template_id] column. + * + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) + */ + public function setTemplateId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->template_id !== $v) { + $this->template_id = $v; + $this->modifiedColumns[] = ProductTableMap::TEMPLATE_ID; + } + + if ($this->aTemplate !== null && $this->aTemplate->getId() !== $v) { + $this->aTemplate = null; + } + + + return $this; + } // setTemplateId() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -1021,28 +1070,31 @@ abstract class Product implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->template_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); @@ -1052,7 +1104,7 @@ abstract class Product implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = ProductTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 11; // 11 = ProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Product object", 0, $e); @@ -1077,6 +1129,9 @@ abstract class Product implements ActiveRecordInterface if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) { $this->aTaxRule = null; } + if ($this->aTemplate !== null && $this->template_id !== $this->aTemplate->getId()) { + $this->aTemplate = null; + } } // ensureConsistency /** @@ -1117,6 +1172,7 @@ abstract class Product implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aTaxRule = null; + $this->aTemplate = null; $this->collProductCategories = null; $this->collFeatureProducts = null; @@ -1288,6 +1344,13 @@ abstract class Product implements ActiveRecordInterface $this->setTaxRule($this->aTaxRule); } + if ($this->aTemplate !== null) { + if ($this->aTemplate->isModified() || $this->aTemplate->isNew()) { + $affectedRows += $this->aTemplate->save($con); + } + $this->setTemplate($this->aTemplate); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1608,6 +1671,9 @@ abstract class Product implements ActiveRecordInterface if ($this->isColumnModified(ProductTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = 'POSITION'; } + if ($this->isColumnModified(ProductTableMap::TEMPLATE_ID)) { + $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; + } if ($this->isColumnModified(ProductTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1649,6 +1715,9 @@ abstract class Product implements ActiveRecordInterface case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; + case 'TEMPLATE_ID': + $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1742,18 +1811,21 @@ abstract class Product implements ActiveRecordInterface return $this->getPosition(); break; case 5: - return $this->getCreatedAt(); + return $this->getTemplateId(); break; case 6: - return $this->getUpdatedAt(); + return $this->getCreatedAt(); break; case 7: - return $this->getVersion(); + return $this->getUpdatedAt(); break; case 8: - return $this->getVersionCreatedAt(); + return $this->getVersion(); break; case 9: + return $this->getVersionCreatedAt(); + break; + case 10: return $this->getVersionCreatedBy(); break; default: @@ -1790,11 +1862,12 @@ abstract class Product implements ActiveRecordInterface $keys[2] => $this->getRef(), $keys[3] => $this->getVisible(), $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - $keys[7] => $this->getVersion(), - $keys[8] => $this->getVersionCreatedAt(), - $keys[9] => $this->getVersionCreatedBy(), + $keys[5] => $this->getTemplateId(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), + $keys[8] => $this->getVersion(), + $keys[9] => $this->getVersionCreatedAt(), + $keys[10] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1806,6 +1879,9 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->aTaxRule) { $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aTemplate) { + $result['Template'] = $this->aTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } if (null !== $this->collProductCategories) { $result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1889,18 +1965,21 @@ abstract class Product implements ActiveRecordInterface $this->setPosition($value); break; case 5: - $this->setCreatedAt($value); + $this->setTemplateId($value); break; case 6: - $this->setUpdatedAt($value); + $this->setCreatedAt($value); break; case 7: - $this->setVersion($value); + $this->setUpdatedAt($value); break; case 8: - $this->setVersionCreatedAt($value); + $this->setVersion($value); break; case 9: + $this->setVersionCreatedAt($value); + break; + case 10: $this->setVersionCreatedBy($value); break; } // switch() @@ -1932,11 +2011,12 @@ abstract class Product implements ActiveRecordInterface if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]); + if (array_key_exists($keys[5], $arr)) $this->setTemplateId($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setVersion($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedAt($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setVersionCreatedBy($arr[$keys[10]]); } /** @@ -1953,6 +2033,7 @@ abstract class Product implements ActiveRecordInterface if ($this->isColumnModified(ProductTableMap::REF)) $criteria->add(ProductTableMap::REF, $this->ref); if ($this->isColumnModified(ProductTableMap::VISIBLE)) $criteria->add(ProductTableMap::VISIBLE, $this->visible); if ($this->isColumnModified(ProductTableMap::POSITION)) $criteria->add(ProductTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductTableMap::TEMPLATE_ID)) $criteria->add(ProductTableMap::TEMPLATE_ID, $this->template_id); if ($this->isColumnModified(ProductTableMap::CREATED_AT)) $criteria->add(ProductTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductTableMap::UPDATED_AT)) $criteria->add(ProductTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(ProductTableMap::VERSION)) $criteria->add(ProductTableMap::VERSION, $this->version); @@ -2025,6 +2106,7 @@ abstract class Product implements ActiveRecordInterface $copyObj->setRef($this->getRef()); $copyObj->setVisible($this->getVisible()); $copyObj->setPosition($this->getPosition()); + $copyObj->setTemplateId($this->getTemplateId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -2183,6 +2265,57 @@ abstract class Product implements ActiveRecordInterface return $this->aTaxRule; } + /** + * Declares an association between this object and a ChildTemplate object. + * + * @param ChildTemplate $v + * @return \Thelia\Model\Product The current object (for fluent API support) + * @throws PropelException + */ + public function setTemplate(ChildTemplate $v = null) + { + if ($v === null) { + $this->setTemplateId(NULL); + } else { + $this->setTemplateId($v->getId()); + } + + $this->aTemplate = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildTemplate object, it will not be re-added. + if ($v !== null) { + $v->addProduct($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTemplate object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTemplate The associated ChildTemplate object. + * @throws PropelException + */ + public function getTemplate(ConnectionInterface $con = null) + { + if ($this->aTemplate === null && ($this->template_id !== null)) { + $this->aTemplate = ChildTemplateQuery::create()->findPk($this->template_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aTemplate->addProducts($this); + */ + } + + return $this->aTemplate; + } + /** * Initializes a collection based on the name of a relation. @@ -5349,6 +5482,7 @@ abstract class Product implements ActiveRecordInterface $this->ref = null; $this->visible = null; $this->position = null; + $this->template_id = null; $this->created_at = null; $this->updated_at = null; $this->version = null; @@ -5507,6 +5641,7 @@ abstract class Product implements ActiveRecordInterface } $this->collProductsRelatedByProductId = null; $this->aTaxRule = null; + $this->aTemplate = null; } /** @@ -5781,6 +5916,7 @@ abstract class Product implements ActiveRecordInterface $version->setRef($this->getRef()); $version->setVisible($this->getVisible()); $version->setPosition($this->getPosition()); + $version->setTemplateId($this->getTemplateId()); $version->setCreatedAt($this->getCreatedAt()); $version->setUpdatedAt($this->getUpdatedAt()); $version->setVersion($this->getVersion()); @@ -5828,6 +5964,7 @@ abstract class Product implements ActiveRecordInterface $this->setRef($version->getRef()); $this->setVisible($version->getVisible()); $this->setPosition($version->getPosition()); + $this->setTemplateId($version->getTemplateId()); $this->setCreatedAt($version->getCreatedAt()); $this->setUpdatedAt($version->getUpdatedAt()); $this->setVersion($version->getVersion()); diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php index 62a6ea425..2c6db3184 100644 --- a/core/lib/Thelia/Model/Base/ProductCategory.php +++ b/core/lib/Thelia/Model/Base/ProductCategory.php @@ -70,6 +70,12 @@ abstract class ProductCategory implements ActiveRecordInterface */ protected $category_id; + /** + * The value for the default_category field. + * @var boolean + */ + protected $default_category; + /** * The value for the created_at field. * @var string @@ -376,6 +382,17 @@ abstract class ProductCategory implements ActiveRecordInterface return $this->category_id; } + /** + * Get the [default_category] column value. + * + * @return boolean + */ + public function getDefaultCategory() + { + + return $this->default_category; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -466,6 +483,35 @@ abstract class ProductCategory implements ActiveRecordInterface return $this; } // setCategoryId() + /** + * Sets the value of the [default_category] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\ProductCategory The current object (for fluent API support) + */ + public function setDefaultCategory($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->default_category !== $v) { + $this->default_category = $v; + $this->modifiedColumns[] = ProductCategoryTableMap::DEFAULT_CATEGORY; + } + + + return $this; + } // setDefaultCategory() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -551,13 +597,16 @@ abstract class ProductCategory implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; $this->category_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductCategoryTableMap::translateFieldName('DefaultCategory', TableMap::TYPE_PHPNAME, $indexType)]; + $this->default_category = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -570,7 +619,7 @@ abstract class ProductCategory implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 4; // 4 = ProductCategoryTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = ProductCategoryTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductCategory object", 0, $e); @@ -819,6 +868,9 @@ abstract class ProductCategory implements ActiveRecordInterface if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) { $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; } + if ($this->isColumnModified(ProductCategoryTableMap::DEFAULT_CATEGORY)) { + $modifiedColumns[':p' . $index++] = 'DEFAULT_CATEGORY'; + } if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -842,6 +894,9 @@ abstract class ProductCategory implements ActiveRecordInterface case 'CATEGORY_ID': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; + case 'DEFAULT_CATEGORY': + $stmt->bindValue($identifier, (int) $this->default_category, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -910,9 +965,12 @@ abstract class ProductCategory implements ActiveRecordInterface return $this->getCategoryId(); break; case 2: - return $this->getCreatedAt(); + return $this->getDefaultCategory(); break; case 3: + return $this->getCreatedAt(); + break; + case 4: return $this->getUpdatedAt(); break; default: @@ -946,8 +1004,9 @@ abstract class ProductCategory implements ActiveRecordInterface $result = array( $keys[0] => $this->getProductId(), $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), + $keys[2] => $this->getDefaultCategory(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1003,9 +1062,12 @@ abstract class ProductCategory implements ActiveRecordInterface $this->setCategoryId($value); break; case 2: - $this->setCreatedAt($value); + $this->setDefaultCategory($value); break; case 3: + $this->setCreatedAt($value); + break; + case 4: $this->setUpdatedAt($value); break; } // switch() @@ -1034,8 +1096,9 @@ abstract class ProductCategory implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setProductId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); + if (array_key_exists($keys[2], $arr)) $this->setDefaultCategory($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } /** @@ -1049,6 +1112,7 @@ abstract class ProductCategory implements ActiveRecordInterface if ($this->isColumnModified(ProductCategoryTableMap::PRODUCT_ID)) $criteria->add(ProductCategoryTableMap::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) $criteria->add(ProductCategoryTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(ProductCategoryTableMap::DEFAULT_CATEGORY)) $criteria->add(ProductCategoryTableMap::DEFAULT_CATEGORY, $this->default_category); if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) $criteria->add(ProductCategoryTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) $criteria->add(ProductCategoryTableMap::UPDATED_AT, $this->updated_at); @@ -1123,6 +1187,7 @@ abstract class ProductCategory implements ActiveRecordInterface { $copyObj->setProductId($this->getProductId()); $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setDefaultCategory($this->getDefaultCategory()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1261,6 +1326,7 @@ abstract class ProductCategory implements ActiveRecordInterface { $this->product_id = null; $this->category_id = null; + $this->default_category = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProductCategoryQuery.php b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php index fd40e93c7..df9fc630b 100644 --- a/core/lib/Thelia/Model/Base/ProductCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php @@ -23,11 +23,13 @@ use Thelia\Model\Map\ProductCategoryTableMap; * * @method ChildProductCategoryQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method ChildProductCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column + * @method ChildProductCategoryQuery orderByDefaultCategory($order = Criteria::ASC) Order by the default_category column * @method ChildProductCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildProductCategoryQuery groupByProductId() Group by the product_id column * @method ChildProductCategoryQuery groupByCategoryId() Group by the category_id column + * @method ChildProductCategoryQuery groupByDefaultCategory() Group by the default_category column * @method ChildProductCategoryQuery groupByCreatedAt() Group by the created_at column * @method ChildProductCategoryQuery groupByUpdatedAt() Group by the updated_at column * @@ -48,11 +50,13 @@ use Thelia\Model\Map\ProductCategoryTableMap; * * @method ChildProductCategory findOneByProductId(int $product_id) Return the first ChildProductCategory filtered by the product_id column * @method ChildProductCategory findOneByCategoryId(int $category_id) Return the first ChildProductCategory filtered by the category_id column + * @method ChildProductCategory findOneByDefaultCategory(boolean $default_category) Return the first ChildProductCategory filtered by the default_category column * @method ChildProductCategory findOneByCreatedAt(string $created_at) Return the first ChildProductCategory filtered by the created_at column * @method ChildProductCategory findOneByUpdatedAt(string $updated_at) Return the first ChildProductCategory filtered by the updated_at column * * @method array findByProductId(int $product_id) Return ChildProductCategory objects filtered by the product_id column * @method array findByCategoryId(int $category_id) Return ChildProductCategory objects filtered by the category_id column + * @method array findByDefaultCategory(boolean $default_category) Return ChildProductCategory objects filtered by the default_category column * @method array findByCreatedAt(string $created_at) Return ChildProductCategory objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProductCategory objects filtered by the updated_at column * @@ -143,7 +147,7 @@ abstract class ProductCategoryQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT PRODUCT_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM product_category WHERE PRODUCT_ID = :p0 AND CATEGORY_ID = :p1'; + $sql = 'SELECT PRODUCT_ID, CATEGORY_ID, DEFAULT_CATEGORY, CREATED_AT, UPDATED_AT FROM product_category WHERE PRODUCT_ID = :p0 AND CATEGORY_ID = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -330,6 +334,33 @@ abstract class ProductCategoryQuery extends ModelCriteria return $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); } + /** + * Filter the query on the default_category column + * + * Example usage: + * + * $query->filterByDefaultCategory(true); // WHERE default_category = true + * $query->filterByDefaultCategory('yes'); // WHERE default_category = true + * + * + * @param boolean|string $defaultCategory The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductCategoryQuery The current query, for fluid interface + */ + public function filterByDefaultCategory($defaultCategory = null, $comparison = null) + { + if (is_string($defaultCategory)) { + $default_category = in_array(strtolower($defaultCategory), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(ProductCategoryTableMap::DEFAULT_CATEGORY, $defaultCategory, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 75f05dfcf..9c3b0759c 100644 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -27,6 +27,7 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery orderByRef($order = Criteria::ASC) Order by the ref column * @method ChildProductQuery orderByVisible($order = Criteria::ASC) Order by the visible column * @method ChildProductQuery orderByPosition($order = Criteria::ASC) Order by the position column + * @method ChildProductQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column * @method ChildProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildProductQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -38,6 +39,7 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery groupByRef() Group by the ref column * @method ChildProductQuery groupByVisible() Group by the visible column * @method ChildProductQuery groupByPosition() Group by the position column + * @method ChildProductQuery groupByTemplateId() Group by the template_id column * @method ChildProductQuery groupByCreatedAt() Group by the created_at column * @method ChildProductQuery groupByUpdatedAt() Group by the updated_at column * @method ChildProductQuery groupByVersion() Group by the version column @@ -52,6 +54,10 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinTaxRule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRule relation * @method ChildProductQuery innerJoinTaxRule($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRule relation * + * @method ChildProductQuery leftJoinTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the Template relation + * @method ChildProductQuery rightJoinTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Template relation + * @method ChildProductQuery innerJoinTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the Template relation + * * @method ChildProductQuery leftJoinProductCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductCategory relation * @method ChildProductQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation * @method ChildProductQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation @@ -104,6 +110,7 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProduct findOneByRef(string $ref) Return the first ChildProduct filtered by the ref column * @method ChildProduct findOneByVisible(int $visible) Return the first ChildProduct filtered by the visible column * @method ChildProduct findOneByPosition(int $position) Return the first ChildProduct filtered by the position column + * @method ChildProduct findOneByTemplateId(int $template_id) Return the first ChildProduct filtered by the template_id column * @method ChildProduct findOneByCreatedAt(string $created_at) Return the first ChildProduct filtered by the created_at column * @method ChildProduct findOneByUpdatedAt(string $updated_at) Return the first ChildProduct filtered by the updated_at column * @method ChildProduct findOneByVersion(int $version) Return the first ChildProduct filtered by the version column @@ -115,6 +122,7 @@ use Thelia\Model\Map\ProductTableMap; * @method array findByRef(string $ref) Return ChildProduct objects filtered by the ref column * @method array findByVisible(int $visible) Return ChildProduct objects filtered by the visible column * @method array findByPosition(int $position) Return ChildProduct objects filtered by the position column + * @method array findByTemplateId(int $template_id) Return ChildProduct objects filtered by the template_id column * @method array findByCreatedAt(string $created_at) Return ChildProduct objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProduct objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildProduct objects filtered by the version column @@ -215,7 +223,7 @@ abstract class ProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, TAX_RULE_ID, REF, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM product WHERE ID = :p0'; + $sql = 'SELECT ID, TAX_RULE_ID, REF, VISIBLE, POSITION, TEMPLATE_ID, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -499,6 +507,49 @@ abstract class ProductQuery extends ModelCriteria return $this->addUsingAlias(ProductTableMap::POSITION, $position, $comparison); } + /** + * Filter the query on the template_id column + * + * Example usage: + * + * $query->filterByTemplateId(1234); // WHERE template_id = 1234 + * $query->filterByTemplateId(array(12, 34)); // WHERE template_id IN (12, 34) + * $query->filterByTemplateId(array('min' => 12)); // WHERE template_id > 12 + * + * + * @see filterByTemplate() + * + * @param mixed $templateId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function filterByTemplateId($templateId = null, $comparison = null) + { + if (is_array($templateId)) { + $useMinMax = false; + if (isset($templateId['min'])) { + $this->addUsingAlias(ProductTableMap::TEMPLATE_ID, $templateId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($templateId['max'])) { + $this->addUsingAlias(ProductTableMap::TEMPLATE_ID, $templateId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductTableMap::TEMPLATE_ID, $templateId, $comparison); + } + /** * Filter the query on the created_at column * @@ -773,6 +824,81 @@ abstract class ProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery'); } + /** + * Filter the query by a related \Thelia\Model\Template object + * + * @param \Thelia\Model\Template|ObjectCollection $template The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function filterByTemplate($template, $comparison = null) + { + if ($template instanceof \Thelia\Model\Template) { + return $this + ->addUsingAlias(ProductTableMap::TEMPLATE_ID, $template->getId(), $comparison); + } elseif ($template instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductTableMap::TEMPLATE_ID, $template->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByTemplate() only accepts arguments of type \Thelia\Model\Template or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Template relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function joinTemplate($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Template'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Template'); + } + + return $this; + } + + /** + * Use the Template relation Template object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query + */ + public function useTemplateQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Template', '\Thelia\Model\TemplateQuery'); + } + /** * Filter the query by a related \Thelia\Model\ProductCategory object * diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php index 071dfc742..a5d22e498 100644 --- a/core/lib/Thelia/Model/Base/ProductVersion.php +++ b/core/lib/Thelia/Model/Base/ProductVersion.php @@ -86,6 +86,12 @@ abstract class ProductVersion implements ActiveRecordInterface */ protected $position; + /** + * The value for the template_id field. + * @var int + */ + protected $template_id; + /** * The value for the created_at field. * @var string @@ -453,6 +459,17 @@ abstract class ProductVersion implements ActiveRecordInterface return $this->position; } + /** + * Get the [template_id] column value. + * + * @return int + */ + public function getTemplateId() + { + + return $this->template_id; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -644,6 +661,27 @@ abstract class ProductVersion implements ActiveRecordInterface return $this; } // setPosition() + /** + * Set the value of [template_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) + */ + public function setTemplateId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->template_id !== $v) { + $this->template_id = $v; + $this->modifiedColumns[] = ProductVersionTableMap::TEMPLATE_ID; + } + + + return $this; + } // setTemplateId() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -809,28 +847,31 @@ abstract class ProductVersion implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductVersionTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->template_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); @@ -840,7 +881,7 @@ abstract class ProductVersion implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = ProductVersionTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 11; // 11 = ProductVersionTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductVersion object", 0, $e); @@ -1076,6 +1117,9 @@ abstract class ProductVersion implements ActiveRecordInterface if ($this->isColumnModified(ProductVersionTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = 'POSITION'; } + if ($this->isColumnModified(ProductVersionTableMap::TEMPLATE_ID)) { + $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; + } if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1117,6 +1161,9 @@ abstract class ProductVersion implements ActiveRecordInterface case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; + case 'TEMPLATE_ID': + $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1203,18 +1250,21 @@ abstract class ProductVersion implements ActiveRecordInterface return $this->getPosition(); break; case 5: - return $this->getCreatedAt(); + return $this->getTemplateId(); break; case 6: - return $this->getUpdatedAt(); + return $this->getCreatedAt(); break; case 7: - return $this->getVersion(); + return $this->getUpdatedAt(); break; case 8: - return $this->getVersionCreatedAt(); + return $this->getVersion(); break; case 9: + return $this->getVersionCreatedAt(); + break; + case 10: return $this->getVersionCreatedBy(); break; default: @@ -1251,11 +1301,12 @@ abstract class ProductVersion implements ActiveRecordInterface $keys[2] => $this->getRef(), $keys[3] => $this->getVisible(), $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - $keys[7] => $this->getVersion(), - $keys[8] => $this->getVersionCreatedAt(), - $keys[9] => $this->getVersionCreatedBy(), + $keys[5] => $this->getTemplateId(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), + $keys[8] => $this->getVersion(), + $keys[9] => $this->getVersionCreatedAt(), + $keys[10] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1317,18 +1368,21 @@ abstract class ProductVersion implements ActiveRecordInterface $this->setPosition($value); break; case 5: - $this->setCreatedAt($value); + $this->setTemplateId($value); break; case 6: - $this->setUpdatedAt($value); + $this->setCreatedAt($value); break; case 7: - $this->setVersion($value); + $this->setUpdatedAt($value); break; case 8: - $this->setVersionCreatedAt($value); + $this->setVersion($value); break; case 9: + $this->setVersionCreatedAt($value); + break; + case 10: $this->setVersionCreatedBy($value); break; } // switch() @@ -1360,11 +1414,12 @@ abstract class ProductVersion implements ActiveRecordInterface if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]); + if (array_key_exists($keys[5], $arr)) $this->setTemplateId($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setVersion($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedAt($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setVersionCreatedBy($arr[$keys[10]]); } /** @@ -1381,6 +1436,7 @@ abstract class ProductVersion implements ActiveRecordInterface if ($this->isColumnModified(ProductVersionTableMap::REF)) $criteria->add(ProductVersionTableMap::REF, $this->ref); if ($this->isColumnModified(ProductVersionTableMap::VISIBLE)) $criteria->add(ProductVersionTableMap::VISIBLE, $this->visible); if ($this->isColumnModified(ProductVersionTableMap::POSITION)) $criteria->add(ProductVersionTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductVersionTableMap::TEMPLATE_ID)) $criteria->add(ProductVersionTableMap::TEMPLATE_ID, $this->template_id); if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) $criteria->add(ProductVersionTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductVersionTableMap::UPDATED_AT)) $criteria->add(ProductVersionTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(ProductVersionTableMap::VERSION)) $criteria->add(ProductVersionTableMap::VERSION, $this->version); @@ -1461,6 +1517,7 @@ abstract class ProductVersion implements ActiveRecordInterface $copyObj->setRef($this->getRef()); $copyObj->setVisible($this->getVisible()); $copyObj->setPosition($this->getPosition()); + $copyObj->setTemplateId($this->getTemplateId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -1554,6 +1611,7 @@ abstract class ProductVersion implements ActiveRecordInterface $this->ref = null; $this->visible = null; $this->position = null; + $this->template_id = null; $this->created_at = null; $this->updated_at = null; $this->version = null; diff --git a/core/lib/Thelia/Model/Base/ProductVersionQuery.php b/core/lib/Thelia/Model/Base/ProductVersionQuery.php index 1b43f7e66..b659becb9 100644 --- a/core/lib/Thelia/Model/Base/ProductVersionQuery.php +++ b/core/lib/Thelia/Model/Base/ProductVersionQuery.php @@ -26,6 +26,7 @@ use Thelia\Model\Map\ProductVersionTableMap; * @method ChildProductVersionQuery orderByRef($order = Criteria::ASC) Order by the ref column * @method ChildProductVersionQuery orderByVisible($order = Criteria::ASC) Order by the visible column * @method ChildProductVersionQuery orderByPosition($order = Criteria::ASC) Order by the position column + * @method ChildProductVersionQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column * @method ChildProductVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildProductVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -37,6 +38,7 @@ use Thelia\Model\Map\ProductVersionTableMap; * @method ChildProductVersionQuery groupByRef() Group by the ref column * @method ChildProductVersionQuery groupByVisible() Group by the visible column * @method ChildProductVersionQuery groupByPosition() Group by the position column + * @method ChildProductVersionQuery groupByTemplateId() Group by the template_id column * @method ChildProductVersionQuery groupByCreatedAt() Group by the created_at column * @method ChildProductVersionQuery groupByUpdatedAt() Group by the updated_at column * @method ChildProductVersionQuery groupByVersion() Group by the version column @@ -59,6 +61,7 @@ use Thelia\Model\Map\ProductVersionTableMap; * @method ChildProductVersion findOneByRef(string $ref) Return the first ChildProductVersion filtered by the ref column * @method ChildProductVersion findOneByVisible(int $visible) Return the first ChildProductVersion filtered by the visible column * @method ChildProductVersion findOneByPosition(int $position) Return the first ChildProductVersion filtered by the position column + * @method ChildProductVersion findOneByTemplateId(int $template_id) Return the first ChildProductVersion filtered by the template_id column * @method ChildProductVersion findOneByCreatedAt(string $created_at) Return the first ChildProductVersion filtered by the created_at column * @method ChildProductVersion findOneByUpdatedAt(string $updated_at) Return the first ChildProductVersion filtered by the updated_at column * @method ChildProductVersion findOneByVersion(int $version) Return the first ChildProductVersion filtered by the version column @@ -70,6 +73,7 @@ use Thelia\Model\Map\ProductVersionTableMap; * @method array findByRef(string $ref) Return ChildProductVersion objects filtered by the ref column * @method array findByVisible(int $visible) Return ChildProductVersion objects filtered by the visible column * @method array findByPosition(int $position) Return ChildProductVersion objects filtered by the position column + * @method array findByTemplateId(int $template_id) Return ChildProductVersion objects filtered by the template_id column * @method array findByCreatedAt(string $created_at) Return ChildProductVersion objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProductVersion objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildProductVersion objects filtered by the version column @@ -163,7 +167,7 @@ abstract class ProductVersionQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, TAX_RULE_ID, REF, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM product_version WHERE ID = :p0 AND VERSION = :p1'; + $sql = 'SELECT ID, TAX_RULE_ID, REF, VISIBLE, POSITION, TEMPLATE_ID, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM product_version WHERE ID = :p0 AND VERSION = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -459,6 +463,47 @@ abstract class ProductVersionQuery extends ModelCriteria return $this->addUsingAlias(ProductVersionTableMap::POSITION, $position, $comparison); } + /** + * Filter the query on the template_id column + * + * Example usage: + * + * $query->filterByTemplateId(1234); // WHERE template_id = 1234 + * $query->filterByTemplateId(array(12, 34)); // WHERE template_id IN (12, 34) + * $query->filterByTemplateId(array('min' => 12)); // WHERE template_id > 12 + * + * + * @param mixed $templateId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductVersionQuery The current query, for fluid interface + */ + public function filterByTemplateId($templateId = null, $comparison = null) + { + if (is_array($templateId)) { + $useMinMax = false; + if (isset($templateId['min'])) { + $this->addUsingAlias(ProductVersionTableMap::TEMPLATE_ID, $templateId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($templateId['max'])) { + $this->addUsingAlias(ProductVersionTableMap::TEMPLATE_ID, $templateId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductVersionTableMap::TEMPLATE_ID, $templateId, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index 61f21d4e1..b361567d8 100644 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -67,6 +67,13 @@ abstract class TaxRule implements ActiveRecordInterface */ protected $id; + /** + * The value for the is_default field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $is_default; + /** * The value for the created_at field. * @var string @@ -137,11 +144,24 @@ abstract class TaxRule implements ActiveRecordInterface */ protected $taxRuleI18nsScheduledForDeletion = null; + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->is_default = false; + } + /** * Initializes internal state of Thelia\Model\Base\TaxRule object. + * @see applyDefaults() */ public function __construct() { + $this->applyDefaultValues(); } /** @@ -402,6 +422,17 @@ abstract class TaxRule implements ActiveRecordInterface return $this->id; } + /** + * Get the [is_default] column value. + * + * @return boolean + */ + public function getIsDefault() + { + + return $this->is_default; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -463,6 +494,35 @@ abstract class TaxRule implements ActiveRecordInterface return $this; } // setId() + /** + * Sets the value of the [is_default] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\TaxRule The current object (for fluent API support) + */ + public function setIsDefault($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_default !== $v) { + $this->is_default = $v; + $this->modifiedColumns[] = TaxRuleTableMap::IS_DEFAULT; + } + + + return $this; + } // setIsDefault() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -515,6 +575,10 @@ abstract class TaxRule implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { + if ($this->is_default !== false) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -545,13 +609,16 @@ abstract class TaxRule implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_default = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -564,7 +631,7 @@ abstract class TaxRule implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 3; // 3 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 4; // 4 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\TaxRule object", 0, $e); @@ -845,6 +912,9 @@ abstract class TaxRule implements ActiveRecordInterface if ($this->isColumnModified(TaxRuleTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } + if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; + } if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -865,6 +935,9 @@ abstract class TaxRule implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; + case 'IS_DEFAULT': + $stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -937,9 +1010,12 @@ abstract class TaxRule implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getCreatedAt(); + return $this->getIsDefault(); break; case 2: + return $this->getCreatedAt(); + break; + case 3: return $this->getUpdatedAt(); break; default: @@ -972,8 +1048,9 @@ abstract class TaxRule implements ActiveRecordInterface $keys = TaxRuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getCreatedAt(), - $keys[2] => $this->getUpdatedAt(), + $keys[1] => $this->getIsDefault(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1029,9 +1106,12 @@ abstract class TaxRule implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setCreatedAt($value); + $this->setIsDefault($value); break; case 2: + $this->setCreatedAt($value); + break; + case 3: $this->setUpdatedAt($value); break; } // switch() @@ -1059,8 +1139,9 @@ abstract class TaxRule implements ActiveRecordInterface $keys = TaxRuleTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setUpdatedAt($arr[$keys[2]]); + if (array_key_exists($keys[1], $arr)) $this->setIsDefault($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); } /** @@ -1073,6 +1154,7 @@ abstract class TaxRule implements ActiveRecordInterface $criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME); if ($this->isColumnModified(TaxRuleTableMap::ID)) $criteria->add(TaxRuleTableMap::ID, $this->id); + if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) $criteria->add(TaxRuleTableMap::IS_DEFAULT, $this->is_default); if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) $criteria->add(TaxRuleTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) $criteria->add(TaxRuleTableMap::UPDATED_AT, $this->updated_at); @@ -1138,6 +1220,7 @@ abstract class TaxRule implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { + $copyObj->setIsDefault($this->getIsDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1434,6 +1517,31 @@ abstract class TaxRule implements ActiveRecordInterface return $this; } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this TaxRule is new, it will return + * an empty collection; or if this TaxRule has previously + * been saved, it will retrieve related Products from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in TaxRule. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProduct[] List of ChildProduct objects + */ + public function getProductsJoinTemplate($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProductQuery::create(null, $criteria); + $query->joinWith('Template', $joinBehavior); + + return $this->getProducts($query, $con); + } + /** * Clears out the collTaxRuleCountries collection * @@ -1936,10 +2044,12 @@ abstract class TaxRule implements ActiveRecordInterface public function clear() { $this->id = null; + $this->is_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php index 8ee264415..bc20c44b1 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php @@ -23,10 +23,12 @@ use Thelia\Model\Map\TaxRuleTableMap; * * * @method ChildTaxRuleQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildTaxRuleQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column * @method ChildTaxRuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildTaxRuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildTaxRuleQuery groupById() Group by the id column + * @method ChildTaxRuleQuery groupByIsDefault() Group by the is_default column * @method ChildTaxRuleQuery groupByCreatedAt() Group by the created_at column * @method ChildTaxRuleQuery groupByUpdatedAt() Group by the updated_at column * @@ -50,10 +52,12 @@ use Thelia\Model\Map\TaxRuleTableMap; * @method ChildTaxRule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTaxRule matching the query, or a new ChildTaxRule object populated from the query conditions when no match is found * * @method ChildTaxRule findOneById(int $id) Return the first ChildTaxRule filtered by the id column + * @method ChildTaxRule findOneByIsDefault(boolean $is_default) Return the first ChildTaxRule filtered by the is_default column * @method ChildTaxRule findOneByCreatedAt(string $created_at) Return the first ChildTaxRule filtered by the created_at column * @method ChildTaxRule findOneByUpdatedAt(string $updated_at) Return the first ChildTaxRule filtered by the updated_at column * * @method array findById(int $id) Return ChildTaxRule objects filtered by the id column + * @method array findByIsDefault(boolean $is_default) Return ChildTaxRule objects filtered by the is_default column * @method array findByCreatedAt(string $created_at) Return ChildTaxRule objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildTaxRule objects filtered by the updated_at column * @@ -144,7 +148,7 @@ abstract class TaxRuleQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0'; + $sql = 'SELECT ID, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -274,6 +278,33 @@ abstract class TaxRuleQuery extends ModelCriteria return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $comparison); } + /** + * Filter the query on the is_default column + * + * Example usage: + * + * $query->filterByIsDefault(true); // WHERE is_default = true + * $query->filterByIsDefault('yes'); // WHERE is_default = true + * + * + * @param boolean|string $isDefault The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTaxRuleQuery The current query, for fluid interface + */ + public function filterByIsDefault($isDefault = null, $comparison = null) + { + if (is_string($isDefault)) { + $is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(TaxRuleTableMap::IS_DEFAULT, $isDefault, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Template.php b/core/lib/Thelia/Model/Base/Template.php new file mode 100644 index 000000000..08bb0f3a0 --- /dev/null +++ b/core/lib/Thelia/Model/Base/Template.php @@ -0,0 +1,3020 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Template instance. If + * obj is an instance of Template, delegates to + * equals(Template). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Template The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Template The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = TemplateTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = TemplateTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = TemplateTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TemplateTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 3; // 3 = TemplateTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Template object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(TemplateTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildTemplateQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->collProducts = null; + + $this->collFeatureTemplates = null; + + $this->collAttributeTemplates = null; + + $this->collTemplateI18ns = null; + + $this->collFeatures = null; + $this->collAttributes = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Template::setDeleted() + * @see Template::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildTemplateQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TemplateTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TemplateTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TemplateTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + TemplateTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->featuresScheduledForDeletion !== null) { + if (!$this->featuresScheduledForDeletion->isEmpty()) { + $pks = array(); + $pk = $this->getPrimaryKey(); + foreach ($this->featuresScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pks[] = array($remotePk, $pk); + } + + FeatureTemplateQuery::create() + ->filterByPrimaryKeys($pks) + ->delete($con); + $this->featuresScheduledForDeletion = null; + } + + foreach ($this->getFeatures() as $feature) { + if ($feature->isModified()) { + $feature->save($con); + } + } + } elseif ($this->collFeatures) { + foreach ($this->collFeatures as $feature) { + if ($feature->isModified()) { + $feature->save($con); + } + } + } + + if ($this->attributesScheduledForDeletion !== null) { + if (!$this->attributesScheduledForDeletion->isEmpty()) { + $pks = array(); + $pk = $this->getPrimaryKey(); + foreach ($this->attributesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pks[] = array($remotePk, $pk); + } + + AttributeTemplateQuery::create() + ->filterByPrimaryKeys($pks) + ->delete($con); + $this->attributesScheduledForDeletion = null; + } + + foreach ($this->getAttributes() as $attribute) { + if ($attribute->isModified()) { + $attribute->save($con); + } + } + } elseif ($this->collAttributes) { + foreach ($this->collAttributes as $attribute) { + if ($attribute->isModified()) { + $attribute->save($con); + } + } + } + + if ($this->productsScheduledForDeletion !== null) { + if (!$this->productsScheduledForDeletion->isEmpty()) { + foreach ($this->productsScheduledForDeletion as $product) { + // need to save related object because we set the relation to null + $product->save($con); + } + $this->productsScheduledForDeletion = null; + } + } + + if ($this->collProducts !== null) { + foreach ($this->collProducts as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->featureTemplatesScheduledForDeletion !== null) { + if (!$this->featureTemplatesScheduledForDeletion->isEmpty()) { + \Thelia\Model\FeatureTemplateQuery::create() + ->filterByPrimaryKeys($this->featureTemplatesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->featureTemplatesScheduledForDeletion = null; + } + } + + if ($this->collFeatureTemplates !== null) { + foreach ($this->collFeatureTemplates as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->attributeTemplatesScheduledForDeletion !== null) { + if (!$this->attributeTemplatesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AttributeTemplateQuery::create() + ->filterByPrimaryKeys($this->attributeTemplatesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->attributeTemplatesScheduledForDeletion = null; + } + } + + if ($this->collAttributeTemplates !== null) { + foreach ($this->collAttributeTemplates as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->templateI18nsScheduledForDeletion !== null) { + if (!$this->templateI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\TemplateI18nQuery::create() + ->filterByPrimaryKeys($this->templateI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->templateI18nsScheduledForDeletion = null; + } + } + + if ($this->collTemplateI18ns !== null) { + foreach ($this->collTemplateI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = TemplateTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . TemplateTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(TemplateTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(TemplateTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(TemplateTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO template (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = TemplateTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCreatedAt(); + break; + case 2: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Template'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Template'][$this->getPrimaryKey()] = true; + $keys = TemplateTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCreatedAt(), + $keys[2] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collProducts) { + $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collFeatureTemplates) { + $result['FeatureTemplates'] = $this->collFeatureTemplates->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collAttributeTemplates) { + $result['AttributeTemplates'] = $this->collAttributeTemplates->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collTemplateI18ns) { + $result['TemplateI18ns'] = $this->collTemplateI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = TemplateTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCreatedAt($value); + break; + case 2: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = TemplateTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setUpdatedAt($arr[$keys[2]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(TemplateTableMap::DATABASE_NAME); + + if ($this->isColumnModified(TemplateTableMap::ID)) $criteria->add(TemplateTableMap::ID, $this->id); + if ($this->isColumnModified(TemplateTableMap::CREATED_AT)) $criteria->add(TemplateTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(TemplateTableMap::UPDATED_AT)) $criteria->add(TemplateTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(TemplateTableMap::DATABASE_NAME); + $criteria->add(TemplateTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\Template (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getProducts() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProduct($relObj->copy($deepCopy)); + } + } + + foreach ($this->getFeatureTemplates() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFeatureTemplate($relObj->copy($deepCopy)); + } + } + + foreach ($this->getAttributeTemplates() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAttributeTemplate($relObj->copy($deepCopy)); + } + } + + foreach ($this->getTemplateI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addTemplateI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Template Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('Product' == $relationName) { + return $this->initProducts(); + } + if ('FeatureTemplate' == $relationName) { + return $this->initFeatureTemplates(); + } + if ('AttributeTemplate' == $relationName) { + return $this->initAttributeTemplates(); + } + if ('TemplateI18n' == $relationName) { + return $this->initTemplateI18ns(); + } + } + + /** + * Clears out the collProducts collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProducts() + */ + public function clearProducts() + { + $this->collProducts = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProducts collection loaded partially. + */ + public function resetPartialProducts($v = true) + { + $this->collProductsPartial = $v; + } + + /** + * Initializes the collProducts collection. + * + * By default this just sets the collProducts collection to an empty array (like clearcollProducts()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProducts($overrideExisting = true) + { + if (null !== $this->collProducts && !$overrideExisting) { + return; + } + $this->collProducts = new ObjectCollection(); + $this->collProducts->setModel('\Thelia\Model\Product'); + } + + /** + * Gets an array of ChildProduct objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTemplate is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProduct[] List of ChildProduct objects + * @throws PropelException + */ + public function getProducts($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProductsPartial && !$this->isNew(); + if (null === $this->collProducts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProducts) { + // return empty collection + $this->initProducts(); + } else { + $collProducts = ChildProductQuery::create(null, $criteria) + ->filterByTemplate($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProductsPartial && count($collProducts)) { + $this->initProducts(false); + + foreach ($collProducts as $obj) { + if (false == $this->collProducts->contains($obj)) { + $this->collProducts->append($obj); + } + } + + $this->collProductsPartial = true; + } + + $collProducts->getInternalIterator()->rewind(); + + return $collProducts; + } + + if ($partial && $this->collProducts) { + foreach ($this->collProducts as $obj) { + if ($obj->isNew()) { + $collProducts[] = $obj; + } + } + } + + $this->collProducts = $collProducts; + $this->collProductsPartial = false; + } + } + + return $this->collProducts; + } + + /** + * Sets a collection of Product objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $products A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTemplate The current object (for fluent API support) + */ + public function setProducts(Collection $products, ConnectionInterface $con = null) + { + $productsToDelete = $this->getProducts(new Criteria(), $con)->diff($products); + + + $this->productsScheduledForDeletion = $productsToDelete; + + foreach ($productsToDelete as $productRemoved) { + $productRemoved->setTemplate(null); + } + + $this->collProducts = null; + foreach ($products as $product) { + $this->addProduct($product); + } + + $this->collProducts = $products; + $this->collProductsPartial = false; + + return $this; + } + + /** + * Returns the number of related Product objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Product objects. + * @throws PropelException + */ + public function countProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProductsPartial && !$this->isNew(); + if (null === $this->collProducts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProducts) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProducts()); + } + + $query = ChildProductQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTemplate($this) + ->count($con); + } + + return count($this->collProducts); + } + + /** + * Method called to associate a ChildProduct object to this object + * through the ChildProduct foreign key attribute. + * + * @param ChildProduct $l ChildProduct + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function addProduct(ChildProduct $l) + { + if ($this->collProducts === null) { + $this->initProducts(); + $this->collProductsPartial = true; + } + + if (!in_array($l, $this->collProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProduct($l); + } + + return $this; + } + + /** + * @param Product $product The product object to add. + */ + protected function doAddProduct($product) + { + $this->collProducts[]= $product; + $product->setTemplate($this); + } + + /** + * @param Product $product The product object to remove. + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeProduct($product) + { + if ($this->getProducts()->contains($product)) { + $this->collProducts->remove($this->collProducts->search($product)); + if (null === $this->productsScheduledForDeletion) { + $this->productsScheduledForDeletion = clone $this->collProducts; + $this->productsScheduledForDeletion->clear(); + } + $this->productsScheduledForDeletion[]= $product; + $product->setTemplate(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Template is new, it will return + * an empty collection; or if this Template has previously + * been saved, it will retrieve related Products from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Template. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProduct[] List of ChildProduct objects + */ + public function getProductsJoinTaxRule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProductQuery::create(null, $criteria); + $query->joinWith('TaxRule', $joinBehavior); + + return $this->getProducts($query, $con); + } + + /** + * Clears out the collFeatureTemplates collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addFeatureTemplates() + */ + public function clearFeatureTemplates() + { + $this->collFeatureTemplates = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collFeatureTemplates collection loaded partially. + */ + public function resetPartialFeatureTemplates($v = true) + { + $this->collFeatureTemplatesPartial = $v; + } + + /** + * Initializes the collFeatureTemplates collection. + * + * By default this just sets the collFeatureTemplates collection to an empty array (like clearcollFeatureTemplates()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFeatureTemplates($overrideExisting = true) + { + if (null !== $this->collFeatureTemplates && !$overrideExisting) { + return; + } + $this->collFeatureTemplates = new ObjectCollection(); + $this->collFeatureTemplates->setModel('\Thelia\Model\FeatureTemplate'); + } + + /** + * Gets an array of ChildFeatureTemplate objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTemplate is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureTemplate[] List of ChildFeatureTemplate objects + * @throws PropelException + */ + public function getFeatureTemplates($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collFeatureTemplatesPartial && !$this->isNew(); + if (null === $this->collFeatureTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureTemplates) { + // return empty collection + $this->initFeatureTemplates(); + } else { + $collFeatureTemplates = ChildFeatureTemplateQuery::create(null, $criteria) + ->filterByTemplate($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collFeatureTemplatesPartial && count($collFeatureTemplates)) { + $this->initFeatureTemplates(false); + + foreach ($collFeatureTemplates as $obj) { + if (false == $this->collFeatureTemplates->contains($obj)) { + $this->collFeatureTemplates->append($obj); + } + } + + $this->collFeatureTemplatesPartial = true; + } + + $collFeatureTemplates->getInternalIterator()->rewind(); + + return $collFeatureTemplates; + } + + if ($partial && $this->collFeatureTemplates) { + foreach ($this->collFeatureTemplates as $obj) { + if ($obj->isNew()) { + $collFeatureTemplates[] = $obj; + } + } + } + + $this->collFeatureTemplates = $collFeatureTemplates; + $this->collFeatureTemplatesPartial = false; + } + } + + return $this->collFeatureTemplates; + } + + /** + * Sets a collection of FeatureTemplate objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $featureTemplates A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTemplate The current object (for fluent API support) + */ + public function setFeatureTemplates(Collection $featureTemplates, ConnectionInterface $con = null) + { + $featureTemplatesToDelete = $this->getFeatureTemplates(new Criteria(), $con)->diff($featureTemplates); + + + $this->featureTemplatesScheduledForDeletion = $featureTemplatesToDelete; + + foreach ($featureTemplatesToDelete as $featureTemplateRemoved) { + $featureTemplateRemoved->setTemplate(null); + } + + $this->collFeatureTemplates = null; + foreach ($featureTemplates as $featureTemplate) { + $this->addFeatureTemplate($featureTemplate); + } + + $this->collFeatureTemplates = $featureTemplates; + $this->collFeatureTemplatesPartial = false; + + return $this; + } + + /** + * Returns the number of related FeatureTemplate objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related FeatureTemplate objects. + * @throws PropelException + */ + public function countFeatureTemplates(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collFeatureTemplatesPartial && !$this->isNew(); + if (null === $this->collFeatureTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureTemplates) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getFeatureTemplates()); + } + + $query = ChildFeatureTemplateQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTemplate($this) + ->count($con); + } + + return count($this->collFeatureTemplates); + } + + /** + * Method called to associate a ChildFeatureTemplate object to this object + * through the ChildFeatureTemplate foreign key attribute. + * + * @param ChildFeatureTemplate $l ChildFeatureTemplate + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function addFeatureTemplate(ChildFeatureTemplate $l) + { + if ($this->collFeatureTemplates === null) { + $this->initFeatureTemplates(); + $this->collFeatureTemplatesPartial = true; + } + + if (!in_array($l, $this->collFeatureTemplates->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddFeatureTemplate($l); + } + + return $this; + } + + /** + * @param FeatureTemplate $featureTemplate The featureTemplate object to add. + */ + protected function doAddFeatureTemplate($featureTemplate) + { + $this->collFeatureTemplates[]= $featureTemplate; + $featureTemplate->setTemplate($this); + } + + /** + * @param FeatureTemplate $featureTemplate The featureTemplate object to remove. + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeFeatureTemplate($featureTemplate) + { + if ($this->getFeatureTemplates()->contains($featureTemplate)) { + $this->collFeatureTemplates->remove($this->collFeatureTemplates->search($featureTemplate)); + if (null === $this->featureTemplatesScheduledForDeletion) { + $this->featureTemplatesScheduledForDeletion = clone $this->collFeatureTemplates; + $this->featureTemplatesScheduledForDeletion->clear(); + } + $this->featureTemplatesScheduledForDeletion[]= clone $featureTemplate; + $featureTemplate->setTemplate(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Template is new, it will return + * an empty collection; or if this Template has previously + * been saved, it will retrieve related FeatureTemplates from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Template. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureTemplate[] List of ChildFeatureTemplate objects + */ + public function getFeatureTemplatesJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildFeatureTemplateQuery::create(null, $criteria); + $query->joinWith('Feature', $joinBehavior); + + return $this->getFeatureTemplates($query, $con); + } + + /** + * Clears out the collAttributeTemplates collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAttributeTemplates() + */ + public function clearAttributeTemplates() + { + $this->collAttributeTemplates = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collAttributeTemplates collection loaded partially. + */ + public function resetPartialAttributeTemplates($v = true) + { + $this->collAttributeTemplatesPartial = $v; + } + + /** + * Initializes the collAttributeTemplates collection. + * + * By default this just sets the collAttributeTemplates collection to an empty array (like clearcollAttributeTemplates()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAttributeTemplates($overrideExisting = true) + { + if (null !== $this->collAttributeTemplates && !$overrideExisting) { + return; + } + $this->collAttributeTemplates = new ObjectCollection(); + $this->collAttributeTemplates->setModel('\Thelia\Model\AttributeTemplate'); + } + + /** + * Gets an array of ChildAttributeTemplate objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTemplate is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeTemplate[] List of ChildAttributeTemplate objects + * @throws PropelException + */ + public function getAttributeTemplates($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collAttributeTemplatesPartial && !$this->isNew(); + if (null === $this->collAttributeTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeTemplates) { + // return empty collection + $this->initAttributeTemplates(); + } else { + $collAttributeTemplates = ChildAttributeTemplateQuery::create(null, $criteria) + ->filterByTemplate($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collAttributeTemplatesPartial && count($collAttributeTemplates)) { + $this->initAttributeTemplates(false); + + foreach ($collAttributeTemplates as $obj) { + if (false == $this->collAttributeTemplates->contains($obj)) { + $this->collAttributeTemplates->append($obj); + } + } + + $this->collAttributeTemplatesPartial = true; + } + + $collAttributeTemplates->getInternalIterator()->rewind(); + + return $collAttributeTemplates; + } + + if ($partial && $this->collAttributeTemplates) { + foreach ($this->collAttributeTemplates as $obj) { + if ($obj->isNew()) { + $collAttributeTemplates[] = $obj; + } + } + } + + $this->collAttributeTemplates = $collAttributeTemplates; + $this->collAttributeTemplatesPartial = false; + } + } + + return $this->collAttributeTemplates; + } + + /** + * Sets a collection of AttributeTemplate objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $attributeTemplates A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTemplate The current object (for fluent API support) + */ + public function setAttributeTemplates(Collection $attributeTemplates, ConnectionInterface $con = null) + { + $attributeTemplatesToDelete = $this->getAttributeTemplates(new Criteria(), $con)->diff($attributeTemplates); + + + $this->attributeTemplatesScheduledForDeletion = $attributeTemplatesToDelete; + + foreach ($attributeTemplatesToDelete as $attributeTemplateRemoved) { + $attributeTemplateRemoved->setTemplate(null); + } + + $this->collAttributeTemplates = null; + foreach ($attributeTemplates as $attributeTemplate) { + $this->addAttributeTemplate($attributeTemplate); + } + + $this->collAttributeTemplates = $attributeTemplates; + $this->collAttributeTemplatesPartial = false; + + return $this; + } + + /** + * Returns the number of related AttributeTemplate objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related AttributeTemplate objects. + * @throws PropelException + */ + public function countAttributeTemplates(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collAttributeTemplatesPartial && !$this->isNew(); + if (null === $this->collAttributeTemplates || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeTemplates) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAttributeTemplates()); + } + + $query = ChildAttributeTemplateQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTemplate($this) + ->count($con); + } + + return count($this->collAttributeTemplates); + } + + /** + * Method called to associate a ChildAttributeTemplate object to this object + * through the ChildAttributeTemplate foreign key attribute. + * + * @param ChildAttributeTemplate $l ChildAttributeTemplate + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function addAttributeTemplate(ChildAttributeTemplate $l) + { + if ($this->collAttributeTemplates === null) { + $this->initAttributeTemplates(); + $this->collAttributeTemplatesPartial = true; + } + + if (!in_array($l, $this->collAttributeTemplates->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAttributeTemplate($l); + } + + return $this; + } + + /** + * @param AttributeTemplate $attributeTemplate The attributeTemplate object to add. + */ + protected function doAddAttributeTemplate($attributeTemplate) + { + $this->collAttributeTemplates[]= $attributeTemplate; + $attributeTemplate->setTemplate($this); + } + + /** + * @param AttributeTemplate $attributeTemplate The attributeTemplate object to remove. + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeAttributeTemplate($attributeTemplate) + { + if ($this->getAttributeTemplates()->contains($attributeTemplate)) { + $this->collAttributeTemplates->remove($this->collAttributeTemplates->search($attributeTemplate)); + if (null === $this->attributeTemplatesScheduledForDeletion) { + $this->attributeTemplatesScheduledForDeletion = clone $this->collAttributeTemplates; + $this->attributeTemplatesScheduledForDeletion->clear(); + } + $this->attributeTemplatesScheduledForDeletion[]= clone $attributeTemplate; + $attributeTemplate->setTemplate(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Template is new, it will return + * an empty collection; or if this Template has previously + * been saved, it will retrieve related AttributeTemplates from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Template. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeTemplate[] List of ChildAttributeTemplate objects + */ + public function getAttributeTemplatesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAttributeTemplateQuery::create(null, $criteria); + $query->joinWith('Attribute', $joinBehavior); + + return $this->getAttributeTemplates($query, $con); + } + + /** + * Clears out the collTemplateI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addTemplateI18ns() + */ + public function clearTemplateI18ns() + { + $this->collTemplateI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collTemplateI18ns collection loaded partially. + */ + public function resetPartialTemplateI18ns($v = true) + { + $this->collTemplateI18nsPartial = $v; + } + + /** + * Initializes the collTemplateI18ns collection. + * + * By default this just sets the collTemplateI18ns collection to an empty array (like clearcollTemplateI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initTemplateI18ns($overrideExisting = true) + { + if (null !== $this->collTemplateI18ns && !$overrideExisting) { + return; + } + $this->collTemplateI18ns = new ObjectCollection(); + $this->collTemplateI18ns->setModel('\Thelia\Model\TemplateI18n'); + } + + /** + * Gets an array of ChildTemplateI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTemplate is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildTemplateI18n[] List of ChildTemplateI18n objects + * @throws PropelException + */ + public function getTemplateI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collTemplateI18nsPartial && !$this->isNew(); + if (null === $this->collTemplateI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTemplateI18ns) { + // return empty collection + $this->initTemplateI18ns(); + } else { + $collTemplateI18ns = ChildTemplateI18nQuery::create(null, $criteria) + ->filterByTemplate($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collTemplateI18nsPartial && count($collTemplateI18ns)) { + $this->initTemplateI18ns(false); + + foreach ($collTemplateI18ns as $obj) { + if (false == $this->collTemplateI18ns->contains($obj)) { + $this->collTemplateI18ns->append($obj); + } + } + + $this->collTemplateI18nsPartial = true; + } + + $collTemplateI18ns->getInternalIterator()->rewind(); + + return $collTemplateI18ns; + } + + if ($partial && $this->collTemplateI18ns) { + foreach ($this->collTemplateI18ns as $obj) { + if ($obj->isNew()) { + $collTemplateI18ns[] = $obj; + } + } + } + + $this->collTemplateI18ns = $collTemplateI18ns; + $this->collTemplateI18nsPartial = false; + } + } + + return $this->collTemplateI18ns; + } + + /** + * Sets a collection of TemplateI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $templateI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTemplate The current object (for fluent API support) + */ + public function setTemplateI18ns(Collection $templateI18ns, ConnectionInterface $con = null) + { + $templateI18nsToDelete = $this->getTemplateI18ns(new Criteria(), $con)->diff($templateI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->templateI18nsScheduledForDeletion = clone $templateI18nsToDelete; + + foreach ($templateI18nsToDelete as $templateI18nRemoved) { + $templateI18nRemoved->setTemplate(null); + } + + $this->collTemplateI18ns = null; + foreach ($templateI18ns as $templateI18n) { + $this->addTemplateI18n($templateI18n); + } + + $this->collTemplateI18ns = $templateI18ns; + $this->collTemplateI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related TemplateI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related TemplateI18n objects. + * @throws PropelException + */ + public function countTemplateI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collTemplateI18nsPartial && !$this->isNew(); + if (null === $this->collTemplateI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTemplateI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getTemplateI18ns()); + } + + $query = ChildTemplateI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTemplate($this) + ->count($con); + } + + return count($this->collTemplateI18ns); + } + + /** + * Method called to associate a ChildTemplateI18n object to this object + * through the ChildTemplateI18n foreign key attribute. + * + * @param ChildTemplateI18n $l ChildTemplateI18n + * @return \Thelia\Model\Template The current object (for fluent API support) + */ + public function addTemplateI18n(ChildTemplateI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collTemplateI18ns === null) { + $this->initTemplateI18ns(); + $this->collTemplateI18nsPartial = true; + } + + if (!in_array($l, $this->collTemplateI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddTemplateI18n($l); + } + + return $this; + } + + /** + * @param TemplateI18n $templateI18n The templateI18n object to add. + */ + protected function doAddTemplateI18n($templateI18n) + { + $this->collTemplateI18ns[]= $templateI18n; + $templateI18n->setTemplate($this); + } + + /** + * @param TemplateI18n $templateI18n The templateI18n object to remove. + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeTemplateI18n($templateI18n) + { + if ($this->getTemplateI18ns()->contains($templateI18n)) { + $this->collTemplateI18ns->remove($this->collTemplateI18ns->search($templateI18n)); + if (null === $this->templateI18nsScheduledForDeletion) { + $this->templateI18nsScheduledForDeletion = clone $this->collTemplateI18ns; + $this->templateI18nsScheduledForDeletion->clear(); + } + $this->templateI18nsScheduledForDeletion[]= clone $templateI18n; + $templateI18n->setTemplate(null); + } + + return $this; + } + + /** + * Clears out the collFeatures collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addFeatures() + */ + public function clearFeatures() + { + $this->collFeatures = null; // important to set this to NULL since that means it is uninitialized + $this->collFeaturesPartial = null; + } + + /** + * Initializes the collFeatures collection. + * + * By default this just sets the collFeatures collection to an empty collection (like clearFeatures()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initFeatures() + { + $this->collFeatures = new ObjectCollection(); + $this->collFeatures->setModel('\Thelia\Model\Feature'); + } + + /** + * Gets a collection of ChildFeature objects related by a many-to-many relationship + * to the current object by way of the feature_template cross-reference table. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTemplate is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object + * + * @return ObjectCollection|ChildFeature[] List of ChildFeature objects + */ + public function getFeatures($criteria = null, ConnectionInterface $con = null) + { + if (null === $this->collFeatures || null !== $criteria) { + if ($this->isNew() && null === $this->collFeatures) { + // return empty collection + $this->initFeatures(); + } else { + $collFeatures = ChildFeatureQuery::create(null, $criteria) + ->filterByTemplate($this) + ->find($con); + if (null !== $criteria) { + return $collFeatures; + } + $this->collFeatures = $collFeatures; + } + } + + return $this->collFeatures; + } + + /** + * Sets a collection of Feature objects related by a many-to-many relationship + * to the current object by way of the feature_template cross-reference table. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $features A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTemplate The current object (for fluent API support) + */ + public function setFeatures(Collection $features, ConnectionInterface $con = null) + { + $this->clearFeatures(); + $currentFeatures = $this->getFeatures(); + + $this->featuresScheduledForDeletion = $currentFeatures->diff($features); + + foreach ($features as $feature) { + if (!$currentFeatures->contains($feature)) { + $this->doAddFeature($feature); + } + } + + $this->collFeatures = $features; + + return $this; + } + + /** + * Gets the number of ChildFeature objects related by a many-to-many relationship + * to the current object by way of the feature_template cross-reference table. + * + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object + * + * @return int the number of related ChildFeature objects + */ + public function countFeatures($criteria = null, $distinct = false, ConnectionInterface $con = null) + { + if (null === $this->collFeatures || null !== $criteria) { + if ($this->isNew() && null === $this->collFeatures) { + return 0; + } else { + $query = ChildFeatureQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTemplate($this) + ->count($con); + } + } else { + return count($this->collFeatures); + } + } + + /** + * Associate a ChildFeature object to this object + * through the feature_template cross reference table. + * + * @param ChildFeature $feature The ChildFeatureTemplate object to relate + * @return ChildTemplate The current object (for fluent API support) + */ + public function addFeature(ChildFeature $feature) + { + if ($this->collFeatures === null) { + $this->initFeatures(); + } + + if (!$this->collFeatures->contains($feature)) { // only add it if the **same** object is not already associated + $this->doAddFeature($feature); + $this->collFeatures[] = $feature; + } + + return $this; + } + + /** + * @param Feature $feature The feature object to add. + */ + protected function doAddFeature($feature) + { + $featureTemplate = new ChildFeatureTemplate(); + $featureTemplate->setFeature($feature); + $this->addFeatureTemplate($featureTemplate); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$feature->getTemplates()->contains($this)) { + $foreignCollection = $feature->getTemplates(); + $foreignCollection[] = $this; + } + } + + /** + * Remove a ChildFeature object to this object + * through the feature_template cross reference table. + * + * @param ChildFeature $feature The ChildFeatureTemplate object to relate + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeFeature(ChildFeature $feature) + { + if ($this->getFeatures()->contains($feature)) { + $this->collFeatures->remove($this->collFeatures->search($feature)); + + if (null === $this->featuresScheduledForDeletion) { + $this->featuresScheduledForDeletion = clone $this->collFeatures; + $this->featuresScheduledForDeletion->clear(); + } + + $this->featuresScheduledForDeletion[] = $feature; + } + + return $this; + } + + /** + * Clears out the collAttributes collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAttributes() + */ + public function clearAttributes() + { + $this->collAttributes = null; // important to set this to NULL since that means it is uninitialized + $this->collAttributesPartial = null; + } + + /** + * Initializes the collAttributes collection. + * + * By default this just sets the collAttributes collection to an empty collection (like clearAttributes()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initAttributes() + { + $this->collAttributes = new ObjectCollection(); + $this->collAttributes->setModel('\Thelia\Model\Attribute'); + } + + /** + * Gets a collection of ChildAttribute objects related by a many-to-many relationship + * to the current object by way of the attribute_template cross-reference table. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTemplate is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object + * + * @return ObjectCollection|ChildAttribute[] List of ChildAttribute objects + */ + public function getAttributes($criteria = null, ConnectionInterface $con = null) + { + if (null === $this->collAttributes || null !== $criteria) { + if ($this->isNew() && null === $this->collAttributes) { + // return empty collection + $this->initAttributes(); + } else { + $collAttributes = ChildAttributeQuery::create(null, $criteria) + ->filterByTemplate($this) + ->find($con); + if (null !== $criteria) { + return $collAttributes; + } + $this->collAttributes = $collAttributes; + } + } + + return $this->collAttributes; + } + + /** + * Sets a collection of Attribute objects related by a many-to-many relationship + * to the current object by way of the attribute_template cross-reference table. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $attributes A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTemplate The current object (for fluent API support) + */ + public function setAttributes(Collection $attributes, ConnectionInterface $con = null) + { + $this->clearAttributes(); + $currentAttributes = $this->getAttributes(); + + $this->attributesScheduledForDeletion = $currentAttributes->diff($attributes); + + foreach ($attributes as $attribute) { + if (!$currentAttributes->contains($attribute)) { + $this->doAddAttribute($attribute); + } + } + + $this->collAttributes = $attributes; + + return $this; + } + + /** + * Gets the number of ChildAttribute objects related by a many-to-many relationship + * to the current object by way of the attribute_template cross-reference table. + * + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object + * + * @return int the number of related ChildAttribute objects + */ + public function countAttributes($criteria = null, $distinct = false, ConnectionInterface $con = null) + { + if (null === $this->collAttributes || null !== $criteria) { + if ($this->isNew() && null === $this->collAttributes) { + return 0; + } else { + $query = ChildAttributeQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTemplate($this) + ->count($con); + } + } else { + return count($this->collAttributes); + } + } + + /** + * Associate a ChildAttribute object to this object + * through the attribute_template cross reference table. + * + * @param ChildAttribute $attribute The ChildAttributeTemplate object to relate + * @return ChildTemplate The current object (for fluent API support) + */ + public function addAttribute(ChildAttribute $attribute) + { + if ($this->collAttributes === null) { + $this->initAttributes(); + } + + if (!$this->collAttributes->contains($attribute)) { // only add it if the **same** object is not already associated + $this->doAddAttribute($attribute); + $this->collAttributes[] = $attribute; + } + + return $this; + } + + /** + * @param Attribute $attribute The attribute object to add. + */ + protected function doAddAttribute($attribute) + { + $attributeTemplate = new ChildAttributeTemplate(); + $attributeTemplate->setAttribute($attribute); + $this->addAttributeTemplate($attributeTemplate); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$attribute->getTemplates()->contains($this)) { + $foreignCollection = $attribute->getTemplates(); + $foreignCollection[] = $this; + } + } + + /** + * Remove a ChildAttribute object to this object + * through the attribute_template cross reference table. + * + * @param ChildAttribute $attribute The ChildAttributeTemplate object to relate + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeAttribute(ChildAttribute $attribute) + { + if ($this->getAttributes()->contains($attribute)) { + $this->collAttributes->remove($this->collAttributes->search($attribute)); + + if (null === $this->attributesScheduledForDeletion) { + $this->attributesScheduledForDeletion = clone $this->collAttributes; + $this->attributesScheduledForDeletion->clear(); + } + + $this->attributesScheduledForDeletion[] = $attribute; + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collProducts) { + foreach ($this->collProducts as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collFeatureTemplates) { + foreach ($this->collFeatureTemplates as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAttributeTemplates) { + foreach ($this->collAttributeTemplates as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collTemplateI18ns) { + foreach ($this->collTemplateI18ns as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collFeatures) { + foreach ($this->collFeatures as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAttributes) { + foreach ($this->collAttributes as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collProducts instanceof Collection) { + $this->collProducts->clearIterator(); + } + $this->collProducts = null; + if ($this->collFeatureTemplates instanceof Collection) { + $this->collFeatureTemplates->clearIterator(); + } + $this->collFeatureTemplates = null; + if ($this->collAttributeTemplates instanceof Collection) { + $this->collAttributeTemplates->clearIterator(); + } + $this->collAttributeTemplates = null; + if ($this->collTemplateI18ns instanceof Collection) { + $this->collTemplateI18ns->clearIterator(); + } + $this->collTemplateI18ns = null; + if ($this->collFeatures instanceof Collection) { + $this->collFeatures->clearIterator(); + } + $this->collFeatures = null; + if ($this->collAttributes instanceof Collection) { + $this->collAttributes->clearIterator(); + } + $this->collAttributes = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(TemplateTableMap::DEFAULT_STRING_FORMAT); + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildTemplate The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildTemplateI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collTemplateI18ns) { + foreach ($this->collTemplateI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildTemplateI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildTemplateI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addTemplateI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildTemplate The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildTemplateI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collTemplateI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collTemplateI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildTemplateI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + return $this->getCurrentTranslation()->getName(); + } + + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return \Thelia\Model\TemplateI18n The current object (for fluent API support) + */ + public function setName($v) + { $this->getCurrentTranslation()->setName($v); + + return $this; + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildTemplate The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TemplateTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/TemplateI18n.php b/core/lib/Thelia/Model/Base/TemplateI18n.php new file mode 100644 index 000000000..7c61c6983 --- /dev/null +++ b/core/lib/Thelia/Model/Base/TemplateI18n.php @@ -0,0 +1,1265 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\TemplateI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another TemplateI18n instance. If + * obj is an instance of TemplateI18n, delegates to + * equals(TemplateI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return TemplateI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return TemplateI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\TemplateI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = TemplateI18nTableMap::ID; + } + + if ($this->aTemplate !== null && $this->aTemplate->getId() !== $v) { + $this->aTemplate = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\TemplateI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = TemplateI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return \Thelia\Model\TemplateI18n The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = TemplateI18nTableMap::NAME; + } + + + return $this; + } // setName() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TemplateI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TemplateI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TemplateI18nTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; + $this->name = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 3; // 3 = TemplateI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\TemplateI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aTemplate !== null && $this->id !== $this->aTemplate->getId()) { + $this->aTemplate = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(TemplateI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildTemplateI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aTemplate = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see TemplateI18n::setDeleted() + * @see TemplateI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildTemplateI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + TemplateI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aTemplate !== null) { + if ($this->aTemplate->isModified() || $this->aTemplate->isNew()) { + $affectedRows += $this->aTemplate->save($con); + } + $this->setTemplate($this->aTemplate); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(TemplateI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(TemplateI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(TemplateI18nTableMap::NAME)) { + $modifiedColumns[':p' . $index++] = 'NAME'; + } + + $sql = sprintf( + 'INSERT INTO template_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'NAME': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = TemplateI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getName(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['TemplateI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['TemplateI18n'][serialize($this->getPrimaryKey())] = true; + $keys = TemplateI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getName(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aTemplate) { + $result['Template'] = $this->aTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = TemplateI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setName($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = TemplateI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(TemplateI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(TemplateI18nTableMap::ID)) $criteria->add(TemplateI18nTableMap::ID, $this->id); + if ($this->isColumnModified(TemplateI18nTableMap::LOCALE)) $criteria->add(TemplateI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(TemplateI18nTableMap::NAME)) $criteria->add(TemplateI18nTableMap::NAME, $this->name); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(TemplateI18nTableMap::DATABASE_NAME); + $criteria->add(TemplateI18nTableMap::ID, $this->id); + $criteria->add(TemplateI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\TemplateI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setName($this->getName()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\TemplateI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildTemplate object. + * + * @param ChildTemplate $v + * @return \Thelia\Model\TemplateI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setTemplate(ChildTemplate $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aTemplate = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildTemplate object, it will not be re-added. + if ($v !== null) { + $v->addTemplateI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTemplate object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTemplate The associated ChildTemplate object. + * @throws PropelException + */ + public function getTemplate(ConnectionInterface $con = null) + { + if ($this->aTemplate === null && ($this->id !== null)) { + $this->aTemplate = ChildTemplateQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aTemplate->addTemplateI18ns($this); + */ + } + + return $this->aTemplate; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->name = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aTemplate = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(TemplateI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/TemplateI18nQuery.php b/core/lib/Thelia/Model/Base/TemplateI18nQuery.php new file mode 100644 index 000000000..12e7b7d1f --- /dev/null +++ b/core/lib/Thelia/Model/Base/TemplateI18nQuery.php @@ -0,0 +1,508 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildTemplateI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = TemplateI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(TemplateI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildTemplateI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, NAME FROM template_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTemplateI18n(); + $obj->hydrate($row); + TemplateI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildTemplateI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(TemplateI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(TemplateI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(TemplateI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(TemplateI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByTemplate() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TemplateI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TemplateI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(TemplateI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(TemplateI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @param string $name The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function filterByName($name = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($name)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $name)) { + $name = str_replace('*', '%', $name); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(TemplateI18nTableMap::NAME, $name, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Template object + * + * @param \Thelia\Model\Template|ObjectCollection $template The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function filterByTemplate($template, $comparison = null) + { + if ($template instanceof \Thelia\Model\Template) { + return $this + ->addUsingAlias(TemplateI18nTableMap::ID, $template->getId(), $comparison); + } elseif ($template instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(TemplateI18nTableMap::ID, $template->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByTemplate() only accepts arguments of type \Thelia\Model\Template or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Template relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function joinTemplate($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Template'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Template'); + } + + return $this; + } + + /** + * Use the Template relation Template object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query + */ + public function useTemplateQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Template', '\Thelia\Model\TemplateQuery'); + } + + /** + * Exclude object from result + * + * @param ChildTemplateI18n $templateI18n Object to remove from the list of results + * + * @return ChildTemplateI18nQuery The current query, for fluid interface + */ + public function prune($templateI18n = null) + { + if ($templateI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(TemplateI18nTableMap::ID), $templateI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(TemplateI18nTableMap::LOCALE), $templateI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the template_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TemplateI18nTableMap::clearInstancePool(); + TemplateI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTemplateI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTemplateI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TemplateI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + TemplateI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TemplateI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // TemplateI18nQuery diff --git a/core/lib/Thelia/Model/Base/TemplateQuery.php b/core/lib/Thelia/Model/Base/TemplateQuery.php new file mode 100644 index 000000000..98c588dd8 --- /dev/null +++ b/core/lib/Thelia/Model/Base/TemplateQuery.php @@ -0,0 +1,907 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildTemplate|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = TemplateTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(TemplateTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildTemplate A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM template WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTemplate(); + $obj->hydrate($row); + TemplateTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildTemplate|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(TemplateTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(TemplateTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TemplateTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TemplateTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(TemplateTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(TemplateTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(TemplateTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(TemplateTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(TemplateTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(TemplateTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(TemplateTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Product object + * + * @param \Thelia\Model\Product|ObjectCollection $product the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByProduct($product, $comparison = null) + { + if ($product instanceof \Thelia\Model\Product) { + return $this + ->addUsingAlias(TemplateTableMap::ID, $product->getTemplateId(), $comparison); + } elseif ($product instanceof ObjectCollection) { + return $this + ->useProductQuery() + ->filterByPrimaryKeys($product->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Product relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Product'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Product'); + } + + return $this; + } + + /** + * Use the Product relation Product object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + */ + public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\FeatureTemplate object + * + * @param \Thelia\Model\FeatureTemplate|ObjectCollection $featureTemplate the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByFeatureTemplate($featureTemplate, $comparison = null) + { + if ($featureTemplate instanceof \Thelia\Model\FeatureTemplate) { + return $this + ->addUsingAlias(TemplateTableMap::ID, $featureTemplate->getTemplateId(), $comparison); + } elseif ($featureTemplate instanceof ObjectCollection) { + return $this + ->useFeatureTemplateQuery() + ->filterByPrimaryKeys($featureTemplate->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFeatureTemplate() only accepts arguments of type \Thelia\Model\FeatureTemplate or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the FeatureTemplate relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function joinFeatureTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FeatureTemplate'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FeatureTemplate'); + } + + return $this; + } + + /** + * Use the FeatureTemplate relation FeatureTemplate object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FeatureTemplateQuery A secondary query class using the current class as primary query + */ + public function useFeatureTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFeatureTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FeatureTemplate', '\Thelia\Model\FeatureTemplateQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\AttributeTemplate object + * + * @param \Thelia\Model\AttributeTemplate|ObjectCollection $attributeTemplate the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByAttributeTemplate($attributeTemplate, $comparison = null) + { + if ($attributeTemplate instanceof \Thelia\Model\AttributeTemplate) { + return $this + ->addUsingAlias(TemplateTableMap::ID, $attributeTemplate->getTemplateId(), $comparison); + } elseif ($attributeTemplate instanceof ObjectCollection) { + return $this + ->useAttributeTemplateQuery() + ->filterByPrimaryKeys($attributeTemplate->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAttributeTemplate() only accepts arguments of type \Thelia\Model\AttributeTemplate or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the AttributeTemplate relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function joinAttributeTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AttributeTemplate'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'AttributeTemplate'); + } + + return $this; + } + + /** + * Use the AttributeTemplate relation AttributeTemplate object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AttributeTemplateQuery A secondary query class using the current class as primary query + */ + public function useAttributeTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAttributeTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AttributeTemplate', '\Thelia\Model\AttributeTemplateQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\TemplateI18n object + * + * @param \Thelia\Model\TemplateI18n|ObjectCollection $templateI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByTemplateI18n($templateI18n, $comparison = null) + { + if ($templateI18n instanceof \Thelia\Model\TemplateI18n) { + return $this + ->addUsingAlias(TemplateTableMap::ID, $templateI18n->getId(), $comparison); + } elseif ($templateI18n instanceof ObjectCollection) { + return $this + ->useTemplateI18nQuery() + ->filterByPrimaryKeys($templateI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByTemplateI18n() only accepts arguments of type \Thelia\Model\TemplateI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the TemplateI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function joinTemplateI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('TemplateI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'TemplateI18n'); + } + + return $this; + } + + /** + * Use the TemplateI18n relation TemplateI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\TemplateI18nQuery A secondary query class using the current class as primary query + */ + public function useTemplateI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinTemplateI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'TemplateI18n', '\Thelia\Model\TemplateI18nQuery'); + } + + /** + * Filter the query by a related Feature object + * using the feature_template table as cross reference + * + * @param Feature $feature the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByFeature($feature, $comparison = Criteria::EQUAL) + { + return $this + ->useFeatureTemplateQuery() + ->filterByFeature($feature, $comparison) + ->endUse(); + } + + /** + * Filter the query by a related Attribute object + * using the attribute_template table as cross reference + * + * @param Attribute $attribute the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function filterByAttribute($attribute, $comparison = Criteria::EQUAL) + { + return $this + ->useAttributeTemplateQuery() + ->filterByAttribute($attribute, $comparison) + ->endUse(); + } + + /** + * Exclude object from result + * + * @param ChildTemplate $template Object to remove from the list of results + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function prune($template = null) + { + if ($template) { + $this->addUsingAlias(TemplateTableMap::ID, $template->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the template table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TemplateTableMap::clearInstancePool(); + TemplateTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTemplate or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTemplate object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TemplateTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + TemplateTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TemplateTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'TemplateI18n'; + + return $this + ->joinTemplateI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('TemplateI18n'); + $this->with['TemplateI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildTemplateI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'TemplateI18n', '\Thelia\Model\TemplateI18nQuery'); + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(TemplateTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(TemplateTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TemplateTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TemplateTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(TemplateTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildTemplateQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(TemplateTableMap::CREATED_AT); + } + +} // TemplateQuery diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 55b697379..89eeff249 100755 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -8,6 +8,7 @@ use Thelia\Model\Base\Cart as BaseCart; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; use Thelia\Model\CartItemQuery; +use Thelia\TaxEngine\Calculator; class Cart extends BaseCart { @@ -44,16 +45,18 @@ class Cart extends BaseCart $item->setQuantity($cartItem->getQuantity()); $item->setProductSaleElements($productSaleElements); if ($currentDateTime <= $cartItem->getPriceEndOfLife()) { - $item->setPrice($cartItem->getPrice()); - $item->setPromoPrice($cartItem->getPromoPrice()); + $item->setPrice($cartItem->getPrice()) + ->setPromoPrice($cartItem->getPromoPrice()) + ->setPromo($productSaleElements->getPromo()) // TODO : new price EOF or duplicate current priceEOF from $cartItem ? - $item->setPriceEndOfLife($cartItem->getPriceEndOfLife()); + ->setPriceEndOfLife($cartItem->getPriceEndOfLife()); } else { $productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne(); - $item->setPrice($productPrices->getPrice()); - $item->setPromoPrice($productPrices->getPromoPrice()); - $item->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)); + $item->setPrice($productPrices->getPrice()) + ->setPromoPrice($productPrices->getPromoPrice()) + ->setPromo($productSaleElements->getPromo()) + ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)); } $item->save(); } @@ -72,8 +75,41 @@ class Cart extends BaseCart ; } - public function getTaxedAmount() + public function getTaxedAmount(Country $country) { + $taxCalculator = new Calculator(); + $total = 0; + + foreach($this->getCartItems() as $cartItem) { + $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); + /* we round it for the unit price, before the quantity factor */ + $subtotal = round($taxCalculator->load($cartItem->getProduct(), $country)->getTaxedPrice($subtotal), 2); + $subtotal *= $cartItem->getQuantity(); + + $total += $subtotal; + } + + $total -= $this->getDiscount(); + + return $total; + } + + public function getTotalAmount() + { + $total = 0; + + foreach($this->getCartItems() as $cartItem) { + $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); + $subtotal *= $cartItem->getQuantity(); + + $total += $subtotal; + } + + $total -= $this->getDiscount(); + + return $total; } } diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 5ef6048a5..a1fb3601a 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -8,6 +8,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; use Thelia\Model\ConfigQuery; use Thelia\Core\Event\CartEvent; +use Thelia\TaxEngine\Calculator; class CartItem extends BaseCartItem { @@ -64,4 +65,20 @@ class CartItem extends BaseCartItem return $this; } + public function getRealPrice() + { + return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice(); + } + + public function getTaxedPrice(Country $country) + { + $taxCalculator = new Calculator(); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); + } + + public function getTaxedPromoPrice(Country $country) + { + $taxCalculator = new Calculator(); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); + } } diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index ced10c94b..347a0f7f7 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -15,6 +15,8 @@ class Category extends BaseCategory use \Thelia\Model\Tools\PositionManagementTrait; + use \Thelia\Model\Tools\UrlRewritingTrait; + /** * @return int number of child for the current category */ @@ -23,30 +25,12 @@ class Category extends BaseCategory return CategoryQuery::countChild($this->getId()); } - public function getUrl($locale) - { - return URL::getInstance()->retrieve('category', $this->getId(), $locale)->toString(); - } - /** - * Create a new category. - * - * @param string $title the category title - * @param int $parent the ID of the parent category - * @param string $locale the locale of the title + * {@inheritDoc} */ - public function create($title, $parent, $locale) - { - $this - ->setLocale($locale) - ->setTitle($title) - ->setParent($parent) - ->setVisible(1) - ->setPosition($this->getNextPosition($parent)) - ; - - $this->save(); - } + protected function getRewrittenUrlViewName() { + return 'category'; + } /** * @@ -71,18 +55,36 @@ class Category extends BaseCategory return $countProduct; } + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByParent($this->getParent()); + } + + /** + * {@inheritDoc} + */ public function preInsert(ConnectionInterface $con = null) { + $this->setPosition($this->getNextPosition()); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY, new CategoryEvent($this)); return true; } + /** + * {@inheritDoc} + */ public function postInsert(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY, new CategoryEvent($this)); } + /** + * {@inheritDoc} + */ public function preUpdate(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECATEGORY, new CategoryEvent($this)); @@ -90,16 +92,27 @@ class Category extends BaseCategory return true; } + /** + * {@inheritDoc} + */ public function postUpdate(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::AFTER_UPDATECATEGORY, new CategoryEvent($this)); } + /** + * {@inheritDoc} + */ public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this)); + + return true; } + /** + * {@inheritDoc} + */ public function postDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this)); diff --git a/core/lib/Thelia/Model/CategoryAssociatedContent.php b/core/lib/Thelia/Model/CategoryAssociatedContent.php index 9296e6274..9154767bc 100644 --- a/core/lib/Thelia/Model/CategoryAssociatedContent.php +++ b/core/lib/Thelia/Model/CategoryAssociatedContent.php @@ -3,7 +3,66 @@ namespace Thelia\Model; use Thelia\Model\Base\CategoryAssociatedContent as BaseCategoryAssociatedContent; +use Thelia\Core\Event\CategoryAssociatedContentEvent; +use Thelia\Core\Event\TheliaEvents; +use Propel\Runtime\Connection\ConnectionInterface; class CategoryAssociatedContent extends BaseCategoryAssociatedContent { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this)); + } + } diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php index bd86f1d1e..5724e2df1 100755 --- a/core/lib/Thelia/Model/CategoryDocument.php +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\CategoryDocument as BaseCategoryDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class CategoryDocument extends BaseCategoryDocument +class CategoryDocument extends BaseCategoryDocument { + use \Thelia\Model\Tools\PositionManagementTrait; -} + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByCategory($this->getCategory()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/CategoryI18n.php b/core/lib/Thelia/Model/CategoryI18n.php index bb4e7b3f3..de3e38663 100755 --- a/core/lib/Thelia/Model/CategoryI18n.php +++ b/core/lib/Thelia/Model/CategoryI18n.php @@ -2,8 +2,13 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\CategoryI18n as BaseCategoryI18n; class CategoryI18n extends BaseCategoryI18n { - + public function postInsert(ConnectionInterface $con = null) + { + $category = $this->getCategory(); + $category->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php index ef555f83e..5bf964e10 100755 --- a/core/lib/Thelia/Model/CategoryImage.php +++ b/core/lib/Thelia/Model/CategoryImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\CategoryImage as BaseCategoryImage; +use Propel\Runtime\Connection\ConnectionInterface; - class CategoryImage extends BaseCategoryImage +class CategoryImage extends BaseCategoryImage { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByCategory($this->getCategory()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/Config.php b/core/lib/Thelia/Model/Config.php index a3289af27..cc44e5053 100755 --- a/core/lib/Thelia/Model/Config.php +++ b/core/lib/Thelia/Model/Config.php @@ -65,6 +65,7 @@ class Config extends BaseConfig { */ public function postUpdate(ConnectionInterface $con = null) { + $this->resetQueryCache(); $this->dispatchEvent(TheliaEvents::AFTER_UPDATECONFIG, new ConfigEvent($this)); } @@ -83,6 +84,12 @@ class Config extends BaseConfig { */ public function postDelete(ConnectionInterface $con = null) { + $this->resetQueryCache(); $this->dispatchEvent(TheliaEvents::AFTER_DELETECONFIG, new ConfigEvent($this)); } + + public function resetQueryCache() + { + ConfigQuery::resetCache($this->getName()); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/ConfigQuery.php b/core/lib/Thelia/Model/ConfigQuery.php index ced3783fe..7f65b103d 100755 --- a/core/lib/Thelia/Model/ConfigQuery.php +++ b/core/lib/Thelia/Model/ConfigQuery.php @@ -16,11 +16,32 @@ use Thelia\Model\Base\ConfigQuery as BaseConfigQuery; * */ class ConfigQuery extends BaseConfigQuery { + + protected static $cache = array(); + public static function read($search, $default = null) { + if (array_key_exists($search, self::$cache)) { + return self::$cache[$search]; + } + $value = self::create()->findOneByName($search); - return $value ? $value->getValue() : $default; + self::$cache[$search] = $value ? $value->getValue() : $default; + + return self::$cache[$search]; + } + + public static function resetCache($key = null) + { + if($key) { + if(array_key_exists($key, self::$cache)) { + unset(self::$cache[$key]); + return true; + } + } + self::$cache = array(); + return true; } public static function getDefaultLangWhenNoTranslationAvailable() @@ -35,9 +56,15 @@ class ConfigQuery extends BaseConfigQuery { public static function getPageNotFoundView() { - return self::read("page_not_found_view", '404.html'); + return self::read("page_not_found_view", '404'); } + public static function getPassedUrlView() + { + return self::read('passed_url_view', 'passed-url'); + } + + public static function getActiveTemplate() { return self::read('active-template', 'default'); diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php index 5bc0ba6b2..69ef7d6d7 100755 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -2,13 +2,111 @@ namespace Thelia\Model; +use Propel\Runtime\Propel; +use Thelia\Core\Event\Content\ContentEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Content as BaseContent; +use Thelia\Model\ContentFolderQuery; +use Thelia\Model\Map\ContentTableMap; use Thelia\Tools\URL; +use Propel\Runtime\Connection\ConnectionInterface; class Content extends BaseContent { - public function getUrl($locale) + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + use \Thelia\Model\Tools\UrlRewritingTrait; + + /** + * {@inheritDoc} + */ + protected function getRewrittenUrlViewName() { + return 'content'; + } + + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + + // TODO: Find the default folder for this content, + // and generate the position relative to this folder + } + + public function getDefaultFolderId() { - return URL::getInstance()->retrieve('content', $this->getId(), $locale)->toString(); + // Find default folder + $default_folder = ContentFolderQuery::create() + ->filterByContentId($this->getId()) + ->filterByDefaultFolder(true) + ->findOne(); + + return $default_folder == null ? 0 : $default_folder->getFolderId(); + } + + public function setDefaultFolder($folderId) + { +/* ContentFolderQuery::create() + ->filterByContentId($this->getId) + ->update(array("DefaultFolder" => 0));*/ + + return $this; + } + + public function create($defaultFolderId) + { + $con = Propel::getWriteConnection(ContentTableMap::DATABASE_NAME); + + $con->beginTransaction(); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECONTENT, new ContentEvent($this)); + + try { + $this->save($con); + + $cf = new ContentFolder(); + $cf->setContentId($this->getId()) + ->setFolderId($defaultFolderId) + ->setDefaultFolder(1) + ->save($con); + + $this->setPosition($this->getNextPosition())->save($con); + + $con->commit(); + + $this->dispatchEvent(TheliaEvents::AFTER_CREATECONTENT,new ContentEvent($this)); + } catch(\Exception $ex) { + + $con->rollback(); + + throw $ex; + } + } + + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECONTENT, new ContentEvent($this)); + + return true; + } + + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATECONTENT, new ContentEvent($this)); + } + + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETECONTENT, new ContentEvent($this)); + + return true; + } + + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETECONTENT, new ContentEvent($this)); } } diff --git a/core/lib/Thelia/Model/ContentDocument.php b/core/lib/Thelia/Model/ContentDocument.php index 933a089cb..8ecf3a3a9 100755 --- a/core/lib/Thelia/Model/ContentDocument.php +++ b/core/lib/Thelia/Model/ContentDocument.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\ContentDocument as BaseContentDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class ContentDocument extends BaseContentDocument +class ContentDocument extends BaseContentDocument { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByContent($this->getContent()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/ContentI18n.php b/core/lib/Thelia/Model/ContentI18n.php index 5b29d894f..11713d57b 100755 --- a/core/lib/Thelia/Model/ContentI18n.php +++ b/core/lib/Thelia/Model/ContentI18n.php @@ -2,8 +2,13 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\ContentI18n as BaseContentI18n; class ContentI18n extends BaseContentI18n { - + public function postInsert(ConnectionInterface $con = null) + { + $content = $this->getContent(); + $content->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/ContentImage.php b/core/lib/Thelia/Model/ContentImage.php index 3020e48f3..ac1dcf755 100755 --- a/core/lib/Thelia/Model/ContentImage.php +++ b/core/lib/Thelia/Model/ContentImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\ContentImage as BaseContentImage; +use Propel\Runtime\Connection\ConnectionInterface; - class ContentImage extends BaseContentImage +class ContentImage extends BaseContentImage { + use \Thelia\Model\Tools\PositionManagementTrait; -} + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByContent($this->getContent()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php index 7a7ce1e4a..032de412a 100755 --- a/core/lib/Thelia/Model/Coupon.php +++ b/core/lib/Thelia/Model/Coupon.php @@ -76,7 +76,6 @@ class Coupon extends BaseCoupon ->setType($effect) ->setAmount($amount) ->setIsRemovingPostage($isRemovingPostage) - ->setType($amount) ->setIsEnabled($isEnabled) ->setExpirationDate($expirationDate) ->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers) diff --git a/core/lib/Thelia/Model/CouponRule.php b/core/lib/Thelia/Model/CouponRule.php deleted file mode 100755 index 14c84deb2..000000000 --- a/core/lib/Thelia/Model/CouponRule.php +++ /dev/null @@ -1,9 +0,0 @@ -getRememberMeToken(); + } + + /** + * {@inheritDoc} + */ + public function setToken($token) { + $this->setRememberMeToken($token)->save(); + } + + /** + * {@inheritDoc} + */ + public function getSerial() { + return $this->getRememberMeSerial(); + } + + /** + * {@inheritDoc} + */ + public function setSerial($serial) { + $this->setRememberMeSerial($serial)->save(); + } + /** * {@inheritDoc} */ public function preInsert(ConnectionInterface $con = null) { + // Set the serial number (for auto-login) + $this->setRememberMeSerial(uniqid()); + $this->setRef($this->generateRef()); $this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, new CustomerEvent($this)); diff --git a/core/lib/Thelia/Model/Delivzone.php b/core/lib/Thelia/Model/Delivzone.php deleted file mode 100755 index 58d4f0f7b..000000000 --- a/core/lib/Thelia/Model/Delivzone.php +++ /dev/null @@ -1,9 +0,0 @@ -dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE, new FeatureEvent($this)); + + // Set the current position for the new object + $this->setPosition($this->getNextPosition()); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE, new FeatureEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE, new FeatureEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE, new FeatureEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE, new FeatureEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE, new FeatureEvent($this)); + } + } diff --git a/core/lib/Thelia/Model/FeatureAv.php b/core/lib/Thelia/Model/FeatureAv.php index 68b6fa92a..ae6e35087 100755 --- a/core/lib/Thelia/Model/FeatureAv.php +++ b/core/lib/Thelia/Model/FeatureAv.php @@ -3,7 +3,78 @@ namespace Thelia\Model; use Thelia\Model\Base\FeatureAv as BaseFeatureAv; +use Thelia\Core\Event\TheliaEvents; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\FeatureAvEvent; class FeatureAv extends BaseFeatureAv { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * when dealing with position, be sure to work insite the current feature. + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByFeatureId($this->getFeatureId()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + // Set the current position for the new object + $this->setPosition($this->getNextPosition()); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_AV, new FeatureAvEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_AV, new FeatureAvEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_AV, new FeatureAvEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_AV, new FeatureAvEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_AV, new FeatureAvEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_AV, new FeatureAvEvent($this)); + } + } diff --git a/core/lib/Thelia/Model/FeatureCategory.php b/core/lib/Thelia/Model/FeatureCategory.php deleted file mode 100755 index 62852f3ee..000000000 --- a/core/lib/Thelia/Model/FeatureCategory.php +++ /dev/null @@ -1,9 +0,0 @@ -getId()); } - public function getUrl($locale) - { - return URL::getInstance()->retrieve('folder', $this->getId(), $locale)->toString(); - } - /** * * count all products for current category and sub categories @@ -35,12 +46,60 @@ class Folder extends BaseFolder foreach($children as $child) { - $contentsCount += ProductQuery::create() - ->filterByCategory($child) + $contentsCount += ContentQuery::create() + ->filterByFolder($child) ->count(); } return $contentsCount; } + + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByParent($this->getParent()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFOLDER, new FolderEvent($this)); + + return true; + } + + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFOLDER, new FolderEvent($this)); + } + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFOLDER, new FolderEvent($this)); + + return true; + } + + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFOLDER, new FolderEvent($this)); + } + + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFOLDER, new FolderEvent($this)); + + return true; + } + + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this)); + } } diff --git a/core/lib/Thelia/Model/FolderDocument.php b/core/lib/Thelia/Model/FolderDocument.php index c9644835e..0a86995d2 100755 --- a/core/lib/Thelia/Model/FolderDocument.php +++ b/core/lib/Thelia/Model/FolderDocument.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\FolderDocument as BaseFolderDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class FolderDocument extends BaseFolderDocument +class FolderDocument extends BaseFolderDocument { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByFolder($this->getFolder()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/FolderI18n.php b/core/lib/Thelia/Model/FolderI18n.php index d1044452b..7ede39502 100755 --- a/core/lib/Thelia/Model/FolderI18n.php +++ b/core/lib/Thelia/Model/FolderI18n.php @@ -2,8 +2,14 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\FolderI18n as BaseFolderI18n; class FolderI18n extends BaseFolderI18n { + public function postInsert(ConnectionInterface $con = null) + { + $folder = $this->getFolder(); + $folder->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/FolderImage.php b/core/lib/Thelia/Model/FolderImage.php index 4e6d285f8..58d8f928e 100755 --- a/core/lib/Thelia/Model/FolderImage.php +++ b/core/lib/Thelia/Model/FolderImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\FolderImage as BaseFolderImage; +use Propel\Runtime\Connection\ConnectionInterface; - class FolderImage extends BaseFolderImage +class FolderImage extends BaseFolderImage { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByFolder($this->getFolder()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/Map/AdminTableMap.php b/core/lib/Thelia/Model/Map/AdminTableMap.php index 39decf52c..a4c2cf265 100644 --- a/core/lib/Thelia/Model/Map/AdminTableMap.php +++ b/core/lib/Thelia/Model/Map/AdminTableMap.php @@ -57,7 +57,7 @@ class AdminTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 11; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class AdminTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 11; /** * the column name for the ID field @@ -104,6 +104,16 @@ class AdminTableMap extends TableMap */ const SALT = 'admin.SALT'; + /** + * the column name for the REMEMBER_ME_TOKEN field + */ + const REMEMBER_ME_TOKEN = 'admin.REMEMBER_ME_TOKEN'; + + /** + * the column name for the REMEMBER_ME_SERIAL field + */ + const REMEMBER_ME_SERIAL = 'admin.REMEMBER_ME_SERIAL'; + /** * the column name for the CREATED_AT field */ @@ -126,12 +136,12 @@ class AdminTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AdminTableMap::ID, AdminTableMap::FIRSTNAME, AdminTableMap::LASTNAME, AdminTableMap::LOGIN, AdminTableMap::PASSWORD, AdminTableMap::ALGO, AdminTableMap::SALT, AdminTableMap::CREATED_AT, AdminTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'RememberMeToken', 'RememberMeSerial', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'rememberMeToken', 'rememberMeSerial', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AdminTableMap::ID, AdminTableMap::FIRSTNAME, AdminTableMap::LASTNAME, AdminTableMap::LOGIN, AdminTableMap::PASSWORD, AdminTableMap::ALGO, AdminTableMap::SALT, AdminTableMap::REMEMBER_ME_TOKEN, AdminTableMap::REMEMBER_ME_SERIAL, AdminTableMap::CREATED_AT, AdminTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'REMEMBER_ME_TOKEN', 'REMEMBER_ME_SERIAL', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'remember_me_token', 'remember_me_serial', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -141,12 +151,12 @@ class AdminTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Firstname' => 1, 'Lastname' => 2, 'Login' => 3, 'Password' => 4, 'Algo' => 5, 'Salt' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(AdminTableMap::ID => 0, AdminTableMap::FIRSTNAME => 1, AdminTableMap::LASTNAME => 2, AdminTableMap::LOGIN => 3, AdminTableMap::PASSWORD => 4, AdminTableMap::ALGO => 5, AdminTableMap::SALT => 6, AdminTableMap::CREATED_AT => 7, AdminTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'FIRSTNAME' => 1, 'LASTNAME' => 2, 'LOGIN' => 3, 'PASSWORD' => 4, 'ALGO' => 5, 'SALT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'created_at' => 7, 'updated_at' => 8, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Firstname' => 1, 'Lastname' => 2, 'Login' => 3, 'Password' => 4, 'Algo' => 5, 'Salt' => 6, 'RememberMeToken' => 7, 'RememberMeSerial' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'rememberMeToken' => 7, 'rememberMeSerial' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), + self::TYPE_COLNAME => array(AdminTableMap::ID => 0, AdminTableMap::FIRSTNAME => 1, AdminTableMap::LASTNAME => 2, AdminTableMap::LOGIN => 3, AdminTableMap::PASSWORD => 4, AdminTableMap::ALGO => 5, AdminTableMap::SALT => 6, AdminTableMap::REMEMBER_ME_TOKEN => 7, AdminTableMap::REMEMBER_ME_SERIAL => 8, AdminTableMap::CREATED_AT => 9, AdminTableMap::UPDATED_AT => 10, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FIRSTNAME' => 1, 'LASTNAME' => 2, 'LOGIN' => 3, 'PASSWORD' => 4, 'ALGO' => 5, 'SALT' => 6, 'REMEMBER_ME_TOKEN' => 7, 'REMEMBER_ME_SERIAL' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), + self::TYPE_FIELDNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'remember_me_token' => 7, 'remember_me_serial' => 8, 'created_at' => 9, 'updated_at' => 10, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -172,6 +182,8 @@ class AdminTableMap extends TableMap $this->addColumn('PASSWORD', 'Password', 'VARCHAR', true, 128, null); $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null); $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null); + $this->addColumn('REMEMBER_ME_TOKEN', 'RememberMeToken', 'VARCHAR', false, 255, null); + $this->addColumn('REMEMBER_ME_SERIAL', 'RememberMeSerial', 'VARCHAR', false, 255, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -352,6 +364,8 @@ class AdminTableMap extends TableMap $criteria->addSelectColumn(AdminTableMap::PASSWORD); $criteria->addSelectColumn(AdminTableMap::ALGO); $criteria->addSelectColumn(AdminTableMap::SALT); + $criteria->addSelectColumn(AdminTableMap::REMEMBER_ME_TOKEN); + $criteria->addSelectColumn(AdminTableMap::REMEMBER_ME_SERIAL); $criteria->addSelectColumn(AdminTableMap::CREATED_AT); $criteria->addSelectColumn(AdminTableMap::UPDATED_AT); } else { @@ -362,6 +376,8 @@ class AdminTableMap extends TableMap $criteria->addSelectColumn($alias . '.PASSWORD'); $criteria->addSelectColumn($alias . '.ALGO'); $criteria->addSelectColumn($alias . '.SALT'); + $criteria->addSelectColumn($alias . '.REMEMBER_ME_TOKEN'); + $criteria->addSelectColumn($alias . '.REMEMBER_ME_SERIAL'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php b/core/lib/Thelia/Model/Map/AreaDeliveryModuleTableMap.php similarity index 70% rename from core/lib/Thelia/Model/Map/DelivzoneTableMap.php rename to core/lib/Thelia/Model/Map/AreaDeliveryModuleTableMap.php index ca7c5fa4d..66052e604 100644 --- a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php +++ b/core/lib/Thelia/Model/Map/AreaDeliveryModuleTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\Delivzone; -use Thelia\Model\DelivzoneQuery; +use Thelia\Model\AreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery; /** - * This class defines the structure of the 'delivzone' table. + * This class defines the structure of the 'area_delivery_module' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\DelivzoneQuery; * (i.e. if it's a text column type). * */ -class DelivzoneTableMap extends TableMap +class AreaDeliveryModuleTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.DelivzoneTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.AreaDeliveryModuleTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class DelivzoneTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'delivzone'; + const TABLE_NAME = 'area_delivery_module'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\Delivzone'; + const OM_CLASS = '\\Thelia\\Model\\AreaDeliveryModule'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.Delivzone'; + const CLASS_DEFAULT = 'Thelia.Model.AreaDeliveryModule'; /** * The total number of columns @@ -72,27 +72,27 @@ class DelivzoneTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'delivzone.ID'; + const ID = 'area_delivery_module.ID'; /** * the column name for the AREA_ID field */ - const AREA_ID = 'delivzone.AREA_ID'; + const AREA_ID = 'area_delivery_module.AREA_ID'; /** - * the column name for the DELIVERY field + * the column name for the DELIVERY_MODULE_ID field */ - const DELIVERY = 'delivzone.DELIVERY'; + const DELIVERY_MODULE_ID = 'area_delivery_module.DELIVERY_MODULE_ID'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'delivzone.CREATED_AT'; + const CREATED_AT = 'area_delivery_module.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'delivzone.UPDATED_AT'; + const UPDATED_AT = 'area_delivery_module.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -106,11 +106,11 @@ class DelivzoneTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(DelivzoneTableMap::ID, DelivzoneTableMap::AREA_ID, DelivzoneTableMap::DELIVERY, DelivzoneTableMap::CREATED_AT, DelivzoneTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'AreaId', 'DeliveryModuleId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'deliveryModuleId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaDeliveryModuleTableMap::ID, AreaDeliveryModuleTableMap::AREA_ID, AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, AreaDeliveryModuleTableMap::CREATED_AT, AreaDeliveryModuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY_MODULE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery_module_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class DelivzoneTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(DelivzoneTableMap::ID => 0, DelivzoneTableMap::AREA_ID => 1, DelivzoneTableMap::DELIVERY => 2, DelivzoneTableMap::CREATED_AT => 3, DelivzoneTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'DeliveryModuleId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'deliveryModuleId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaDeliveryModuleTableMap::ID => 0, AreaDeliveryModuleTableMap::AREA_ID => 1, AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID => 2, AreaDeliveryModuleTableMap::CREATED_AT => 3, AreaDeliveryModuleTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY_MODULE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery_module_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -139,15 +139,15 @@ class DelivzoneTableMap extends TableMap public function initialize() { // attributes - $this->setName('delivzone'); - $this->setPhpName('Delivzone'); - $this->setClassName('\\Thelia\\Model\\Delivzone'); + $this->setName('area_delivery_module'); + $this->setPhpName('AreaDeliveryModule'); + $this->setClassName('\\Thelia\\Model\\AreaDeliveryModule'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null); - $this->addColumn('DELIVERY', 'Delivery', 'VARCHAR', true, 45, null); + $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -157,7 +157,8 @@ class DelivzoneTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() /** @@ -229,7 +230,7 @@ class DelivzoneTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? DelivzoneTableMap::CLASS_DEFAULT : DelivzoneTableMap::OM_CLASS; + return $withPrefix ? AreaDeliveryModuleTableMap::CLASS_DEFAULT : AreaDeliveryModuleTableMap::OM_CLASS; } /** @@ -243,21 +244,21 @@ class DelivzoneTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Delivzone object, last column rank) + * @return array (AreaDeliveryModule object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + $key = AreaDeliveryModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + DelivzoneTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + AreaDeliveryModuleTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = DelivzoneTableMap::OM_CLASS; + $cls = AreaDeliveryModuleTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - DelivzoneTableMap::addInstanceToPool($obj, $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -280,8 +281,8 @@ class DelivzoneTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + $key = AreaDeliveryModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -290,7 +291,7 @@ class DelivzoneTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - DelivzoneTableMap::addInstanceToPool($obj, $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -311,15 +312,15 @@ class DelivzoneTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(DelivzoneTableMap::ID); - $criteria->addSelectColumn(DelivzoneTableMap::AREA_ID); - $criteria->addSelectColumn(DelivzoneTableMap::DELIVERY); - $criteria->addSelectColumn(DelivzoneTableMap::CREATED_AT); - $criteria->addSelectColumn(DelivzoneTableMap::UPDATED_AT); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::AREA_ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::CREATED_AT); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.AREA_ID'); - $criteria->addSelectColumn($alias . '.DELIVERY'); + $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -334,7 +335,7 @@ class DelivzoneTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME)->getTable(DelivzoneTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(AreaDeliveryModuleTableMap::DATABASE_NAME)->getTable(AreaDeliveryModuleTableMap::TABLE_NAME); } /** @@ -342,16 +343,16 @@ class DelivzoneTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(DelivzoneTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new DelivzoneTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AreaDeliveryModuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AreaDeliveryModuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AreaDeliveryModuleTableMap()); } } /** - * Performs a DELETE on the database, given a Delivzone or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a AreaDeliveryModule or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Delivzone object or primary key or array of primary keys + * @param mixed $values Criteria or AreaDeliveryModule object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -362,25 +363,25 @@ class DelivzoneTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Delivzone) { // it's a model object + } elseif ($values instanceof \Thelia\Model\AreaDeliveryModule) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); - $criteria->add(DelivzoneTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); + $criteria->add(AreaDeliveryModuleTableMap::ID, (array) $values, Criteria::IN); } - $query = DelivzoneQuery::create()->mergeWith($criteria); + $query = AreaDeliveryModuleQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { DelivzoneTableMap::clearInstancePool(); + if ($values instanceof Criteria) { AreaDeliveryModuleTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { DelivzoneTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { AreaDeliveryModuleTableMap::removeInstanceFromPool($singleval); } } @@ -388,20 +389,20 @@ class DelivzoneTableMap extends TableMap } /** - * Deletes all rows from the delivzone table. + * Deletes all rows from the area_delivery_module table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return DelivzoneQuery::create()->doDeleteAll($con); + return AreaDeliveryModuleQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Delivzone or Criteria object. + * Performs an INSERT on the database, given a AreaDeliveryModule or Criteria object. * - * @param mixed $criteria Criteria or Delivzone object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or AreaDeliveryModule object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -410,22 +411,22 @@ class DelivzoneTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Delivzone object + $criteria = $criteria->buildCriteria(); // build Criteria from AreaDeliveryModule object } - if ($criteria->containsKey(DelivzoneTableMap::ID) && $criteria->keyContainsValue(DelivzoneTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzoneTableMap::ID.')'); + if ($criteria->containsKey(AreaDeliveryModuleTableMap::ID) && $criteria->keyContainsValue(AreaDeliveryModuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaDeliveryModuleTableMap::ID.')'); } // Set the correct dbName - $query = DelivzoneQuery::create()->mergeWith($criteria); + $query = AreaDeliveryModuleQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -441,7 +442,7 @@ class DelivzoneTableMap extends TableMap return $pk; } -} // DelivzoneTableMap +} // AreaDeliveryModuleTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -DelivzoneTableMap::buildTableMap(); +AreaDeliveryModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AreaTableMap.php b/core/lib/Thelia/Model/Map/AreaTableMap.php index 9dc308de5..3c1bc5ee4 100644 --- a/core/lib/Thelia/Model/Map/AreaTableMap.php +++ b/core/lib/Thelia/Model/Map/AreaTableMap.php @@ -80,9 +80,9 @@ class AreaTableMap extends TableMap const NAME = 'area.NAME'; /** - * the column name for the UNIT field + * the column name for the POSTAGE field */ - const UNIT = 'area.UNIT'; + const POSTAGE = 'area.POSTAGE'; /** * the column name for the CREATED_AT field @@ -106,11 +106,11 @@ class AreaTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'name', 'unit', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::UNIT, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'name', 'unit', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Name', 'Postage', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'postage', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::POSTAGE, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'POSTAGE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'postage', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class AreaTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::UNIT => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Postage' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'postage' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::POSTAGE => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'POSTAGE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'postage' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -147,7 +147,7 @@ class AreaTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null); - $this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null); + $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -158,7 +158,7 @@ class AreaTableMap extends TableMap public function buildRelations() { $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Countries'); - $this->addRelation('Delivzone', '\\Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Delivzones'); + $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); } // buildRelations() /** @@ -181,7 +181,7 @@ class AreaTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CountryTableMap::clearInstancePool(); - DelivzoneTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); } /** @@ -324,13 +324,13 @@ class AreaTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(AreaTableMap::ID); $criteria->addSelectColumn(AreaTableMap::NAME); - $criteria->addSelectColumn(AreaTableMap::UNIT); + $criteria->addSelectColumn(AreaTableMap::POSTAGE); $criteria->addSelectColumn(AreaTableMap::CREATED_AT); $criteria->addSelectColumn(AreaTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.UNIT'); + $criteria->addSelectColumn($alias . '.POSTAGE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php index a4b3520e7..c13b85bbf 100644 --- a/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php @@ -159,7 +159,7 @@ class AttributeCombinationTableMap extends TableMap { $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), null, null); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php index 773e13cab..245dc08d3 100644 --- a/core/lib/Thelia/Model/Map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -162,9 +162,9 @@ class AttributeTableMap extends TableMap { $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeAvs'); $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); - $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); + $this->addRelation('AttributeTemplate', '\\Thelia\\Model\\AttributeTemplate', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeTemplates'); $this->addRelation('AttributeI18n', '\\Thelia\\Model\\AttributeI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'AttributeI18ns'); - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories'); + $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_MANY, array(), null, null, 'Templates'); } // buildRelations() /** @@ -189,7 +189,7 @@ class AttributeTableMap extends TableMap // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AttributeAvTableMap::clearInstancePool(); AttributeCombinationTableMap::clearInstancePool(); - AttributeCategoryTableMap::clearInstancePool(); + AttributeTemplateTableMap::clearInstancePool(); AttributeI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php similarity index 71% rename from core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php rename to core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php index b2525e8c3..04d3a9a4a 100644 --- a/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\AttributeCategory; -use Thelia\Model\AttributeCategoryQuery; +use Thelia\Model\AttributeTemplate; +use Thelia\Model\AttributeTemplateQuery; /** - * This class defines the structure of the 'attribute_category' table. + * This class defines the structure of the 'attribute_template' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\AttributeCategoryQuery; * (i.e. if it's a text column type). * */ -class AttributeCategoryTableMap extends TableMap +class AttributeTemplateTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.AttributeCategoryTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.AttributeTemplateTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class AttributeCategoryTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'attribute_category'; + const TABLE_NAME = 'attribute_template'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\AttributeCategory'; + const OM_CLASS = '\\Thelia\\Model\\AttributeTemplate'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.AttributeCategory'; + const CLASS_DEFAULT = 'Thelia.Model.AttributeTemplate'; /** * The total number of columns @@ -72,27 +72,27 @@ class AttributeCategoryTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'attribute_category.ID'; - - /** - * the column name for the CATEGORY_ID field - */ - const CATEGORY_ID = 'attribute_category.CATEGORY_ID'; + const ID = 'attribute_template.ID'; /** * the column name for the ATTRIBUTE_ID field */ - const ATTRIBUTE_ID = 'attribute_category.ATTRIBUTE_ID'; + const ATTRIBUTE_ID = 'attribute_template.ATTRIBUTE_ID'; + + /** + * the column name for the TEMPLATE_ID field + */ + const TEMPLATE_ID = 'attribute_template.TEMPLATE_ID'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'attribute_category.CREATED_AT'; + const CREATED_AT = 'attribute_template.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'attribute_category.UPDATED_AT'; + const UPDATED_AT = 'attribute_template.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -106,11 +106,11 @@ class AttributeCategoryTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'CategoryId', 'AttributeId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'attributeId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID, AttributeCategoryTableMap::CATEGORY_ID, AttributeCategoryTableMap::ATTRIBUTE_ID, AttributeCategoryTableMap::CREATED_AT, AttributeCategoryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'ATTRIBUTE_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'category_id', 'attribute_id', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class AttributeCategoryTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'AttributeId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'attributeId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID => 0, AttributeCategoryTableMap::CATEGORY_ID => 1, AttributeCategoryTableMap::ATTRIBUTE_ID => 2, AttributeCategoryTableMap::CREATED_AT => 3, AttributeCategoryTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'ATTRIBUTE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'attribute_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::CREATED_AT => 3, AttributeTemplateTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -139,16 +139,16 @@ class AttributeCategoryTableMap extends TableMap public function initialize() { // attributes - $this->setName('attribute_category'); - $this->setPhpName('AttributeCategory'); - $this->setClassName('\\Thelia\\Model\\AttributeCategory'); + $this->setName('attribute_template'); + $this->setPhpName('AttributeTemplate'); + $this->setClassName('\\Thelia\\Model\\AttributeTemplate'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); $this->setIsCrossRef(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null); + $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -158,8 +158,8 @@ class AttributeCategoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), null, null); } // buildRelations() /** @@ -231,7 +231,7 @@ class AttributeCategoryTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? AttributeCategoryTableMap::CLASS_DEFAULT : AttributeCategoryTableMap::OM_CLASS; + return $withPrefix ? AttributeTemplateTableMap::CLASS_DEFAULT : AttributeTemplateTableMap::OM_CLASS; } /** @@ -245,21 +245,21 @@ class AttributeCategoryTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (AttributeCategory object, last column rank) + * @return array (AttributeTemplate object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool($key))) { + $key = AttributeTemplateTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeTemplateTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + AttributeTemplateTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = AttributeCategoryTableMap::OM_CLASS; + $cls = AttributeTemplateTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - AttributeCategoryTableMap::addInstanceToPool($obj, $key); + AttributeTemplateTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -282,8 +282,8 @@ class AttributeCategoryTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool($key))) { + $key = AttributeTemplateTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeTemplateTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -292,7 +292,7 @@ class AttributeCategoryTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - AttributeCategoryTableMap::addInstanceToPool($obj, $key); + AttributeTemplateTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -313,15 +313,15 @@ class AttributeCategoryTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(AttributeCategoryTableMap::ID); - $criteria->addSelectColumn(AttributeCategoryTableMap::CATEGORY_ID); - $criteria->addSelectColumn(AttributeCategoryTableMap::ATTRIBUTE_ID); - $criteria->addSelectColumn(AttributeCategoryTableMap::CREATED_AT); - $criteria->addSelectColumn(AttributeCategoryTableMap::UPDATED_AT); + $criteria->addSelectColumn(AttributeTemplateTableMap::ID); + $criteria->addSelectColumn(AttributeTemplateTableMap::ATTRIBUTE_ID); + $criteria->addSelectColumn(AttributeTemplateTableMap::TEMPLATE_ID); + $criteria->addSelectColumn(AttributeTemplateTableMap::CREATED_AT); + $criteria->addSelectColumn(AttributeTemplateTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); + $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -336,7 +336,7 @@ class AttributeCategoryTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME)->getTable(AttributeCategoryTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(AttributeTemplateTableMap::DATABASE_NAME)->getTable(AttributeTemplateTableMap::TABLE_NAME); } /** @@ -344,16 +344,16 @@ class AttributeCategoryTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(AttributeCategoryTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeCategoryTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeTemplateTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeTemplateTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeTemplateTableMap()); } } /** - * Performs a DELETE on the database, given a AttributeCategory or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a AttributeTemplate or Criteria object OR a primary key value. * - * @param mixed $values Criteria or AttributeCategory object or primary key or array of primary keys + * @param mixed $values Criteria or AttributeTemplate object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -364,25 +364,25 @@ class AttributeCategoryTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\AttributeCategory) { // it's a model object + } elseif ($values instanceof \Thelia\Model\AttributeTemplate) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AttributeCategoryTableMap::DATABASE_NAME); - $criteria->add(AttributeCategoryTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(AttributeTemplateTableMap::DATABASE_NAME); + $criteria->add(AttributeTemplateTableMap::ID, (array) $values, Criteria::IN); } - $query = AttributeCategoryQuery::create()->mergeWith($criteria); + $query = AttributeTemplateQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { AttributeCategoryTableMap::clearInstancePool(); + if ($values instanceof Criteria) { AttributeTemplateTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { AttributeCategoryTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { AttributeTemplateTableMap::removeInstanceFromPool($singleval); } } @@ -390,20 +390,20 @@ class AttributeCategoryTableMap extends TableMap } /** - * Deletes all rows from the attribute_category table. + * Deletes all rows from the attribute_template table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return AttributeCategoryQuery::create()->doDeleteAll($con); + return AttributeTemplateQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a AttributeCategory or Criteria object. + * Performs an INSERT on the database, given a AttributeTemplate or Criteria object. * - * @param mixed $criteria Criteria or AttributeCategory object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or AttributeTemplate object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -412,22 +412,22 @@ class AttributeCategoryTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from AttributeCategory object + $criteria = $criteria->buildCriteria(); // build Criteria from AttributeTemplate object } - if ($criteria->containsKey(AttributeCategoryTableMap::ID) && $criteria->keyContainsValue(AttributeCategoryTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCategoryTableMap::ID.')'); + if ($criteria->containsKey(AttributeTemplateTableMap::ID) && $criteria->keyContainsValue(AttributeTemplateTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeTemplateTableMap::ID.')'); } // Set the correct dbName - $query = AttributeCategoryQuery::create()->mergeWith($criteria); + $query = AttributeTemplateQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -443,7 +443,7 @@ class AttributeCategoryTableMap extends TableMap return $pk; } -} // AttributeCategoryTableMap +} // AttributeTemplateTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -AttributeCategoryTableMap::buildTableMap(); +AttributeTemplateTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CartItemTableMap.php b/core/lib/Thelia/Model/Map/CartItemTableMap.php index 7520b39c9..c48d298e0 100644 --- a/core/lib/Thelia/Model/Map/CartItemTableMap.php +++ b/core/lib/Thelia/Model/Map/CartItemTableMap.php @@ -57,7 +57,7 @@ class CartItemTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 11; + const NUM_COLUMNS = 12; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CartItemTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 11; + const NUM_HYDRATE_COLUMNS = 12; /** * the column name for the ID field @@ -114,6 +114,11 @@ class CartItemTableMap extends TableMap */ const DISCOUNT = 'cart_item.DISCOUNT'; + /** + * the column name for the PROMO field + */ + const PROMO = 'cart_item.PROMO'; + /** * the column name for the CREATED_AT field */ @@ -136,12 +141,12 @@ class CartItemTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Discount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'discount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::DISCOUNT, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'discount', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Discount', 'Promo', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'discount', 'promo', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::DISCOUNT, CartItemTableMap::PROMO, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'DISCOUNT', 'PROMO', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'discount', 'promo', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -151,12 +156,12 @@ class CartItemTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Discount' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'discount' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), - self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::DISCOUNT => 8, CartItemTableMap::CREATED_AT => 9, CartItemTableMap::UPDATED_AT => 10, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'DISCOUNT' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), - self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'discount' => 8, 'created_at' => 9, 'updated_at' => 10, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Discount' => 8, 'Promo' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'discount' => 8, 'promo' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), + self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::DISCOUNT => 8, CartItemTableMap::PROMO => 9, CartItemTableMap::CREATED_AT => 10, CartItemTableMap::UPDATED_AT => 11, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'DISCOUNT' => 8, 'PROMO' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), + self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'discount' => 8, 'promo' => 9, 'created_at' => 10, 'updated_at' => 11, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -184,6 +189,7 @@ class CartItemTableMap extends TableMap $this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null); $this->addColumn('PRICE_END_OF_LIFE', 'PriceEndOfLife', 'TIMESTAMP', false, null, null); $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, 0); + $this->addColumn('PROMO', 'Promo', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -358,6 +364,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn(CartItemTableMap::PROMO_PRICE); $criteria->addSelectColumn(CartItemTableMap::PRICE_END_OF_LIFE); $criteria->addSelectColumn(CartItemTableMap::DISCOUNT); + $criteria->addSelectColumn(CartItemTableMap::PROMO); $criteria->addSelectColumn(CartItemTableMap::CREATED_AT); $criteria->addSelectColumn(CartItemTableMap::UPDATED_AT); } else { @@ -370,6 +377,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn($alias . '.PROMO_PRICE'); $criteria->addSelectColumn($alias . '.PRICE_END_OF_LIFE'); $criteria->addSelectColumn($alias . '.DISCOUNT'); + $criteria->addSelectColumn($alias . '.PROMO'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index 6a2d052a1..cd0ca3799 100644 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -191,16 +191,12 @@ class CategoryTableMap extends TableMap public function buildRelations() { $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); - $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); - $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); $this->addRelation('CategoryImage', '\\Thelia\\Model\\CategoryImage', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryImages'); $this->addRelation('CategoryDocument', '\\Thelia\\Model\\CategoryDocument', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryDocuments'); $this->addRelation('CategoryAssociatedContent', '\\Thelia\\Model\\CategoryAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryAssociatedContents'); $this->addRelation('CategoryI18n', '\\Thelia\\Model\\CategoryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryI18ns'); $this->addRelation('CategoryVersion', '\\Thelia\\Model\\CategoryVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryVersions'); $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Products'); - $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Features'); - $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Attributes'); } // buildRelations() /** @@ -225,8 +221,6 @@ class CategoryTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ProductCategoryTableMap::clearInstancePool(); - FeatureCategoryTableMap::clearInstancePool(); - AttributeCategoryTableMap::clearInstancePool(); CategoryImageTableMap::clearInstancePool(); CategoryDocumentTableMap::clearInstancePool(); CategoryAssociatedContentTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php index 4fedae441..9808399ff 100644 --- a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php @@ -57,7 +57,7 @@ class ContentFolderTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 5; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ContentFolderTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 4; + const NUM_HYDRATE_COLUMNS = 5; /** * the column name for the CONTENT_ID field @@ -79,6 +79,11 @@ class ContentFolderTableMap extends TableMap */ const FOLDER_ID = 'content_folder.FOLDER_ID'; + /** + * the column name for the DEFAULT_FOLDER field + */ + const DEFAULT_FOLDER = 'content_folder.DEFAULT_FOLDER'; + /** * the column name for the CREATED_AT field */ @@ -101,12 +106,12 @@ class ContentFolderTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('ContentId', 'FolderId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('contentId', 'folderId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID, ContentFolderTableMap::FOLDER_ID, ContentFolderTableMap::CREATED_AT, ContentFolderTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('CONTENT_ID', 'FOLDER_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('content_id', 'folder_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ContentId', 'FolderId', 'DefaultFolder', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('contentId', 'folderId', 'defaultFolder', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID, ContentFolderTableMap::FOLDER_ID, ContentFolderTableMap::DEFAULT_FOLDER, ContentFolderTableMap::CREATED_AT, ContentFolderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('CONTENT_ID', 'FOLDER_ID', 'DEFAULT_FOLDER', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('content_id', 'folder_id', 'default_folder', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -116,12 +121,12 @@ class ContentFolderTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('ContentId' => 0, 'FolderId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('contentId' => 0, 'folderId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID => 0, ContentFolderTableMap::FOLDER_ID => 1, ContentFolderTableMap::CREATED_AT => 2, ContentFolderTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('content_id' => 0, 'folder_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ContentId' => 0, 'FolderId' => 1, 'DefaultFolder' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('contentId' => 0, 'folderId' => 1, 'defaultFolder' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID => 0, ContentFolderTableMap::FOLDER_ID => 1, ContentFolderTableMap::DEFAULT_FOLDER => 2, ContentFolderTableMap::CREATED_AT => 3, ContentFolderTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'DEFAULT_FOLDER' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('content_id' => 0, 'folder_id' => 1, 'default_folder' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -143,6 +148,7 @@ class ContentFolderTableMap extends TableMap // columns $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null); $this->addForeignPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER' , 'folder', 'ID', true, null, null); + $this->addColumn('DEFAULT_FOLDER', 'DefaultFolder', 'BOOLEAN', false, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -358,11 +364,13 @@ class ContentFolderTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(ContentFolderTableMap::CONTENT_ID); $criteria->addSelectColumn(ContentFolderTableMap::FOLDER_ID); + $criteria->addSelectColumn(ContentFolderTableMap::DEFAULT_FOLDER); $criteria->addSelectColumn(ContentFolderTableMap::CREATED_AT); $criteria->addSelectColumn(ContentFolderTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.CONTENT_ID'); $criteria->addSelectColumn($alias . '.FOLDER_ID'); + $criteria->addSelectColumn($alias . '.DEFAULT_FOLDER'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php index e7c356f08..519af7176 100644 --- a/core/lib/Thelia/Model/Map/CountryTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -57,7 +57,7 @@ class CountryTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 8; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CountryTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; + const NUM_HYDRATE_COLUMNS = 8; /** * the column name for the ID field @@ -94,6 +94,11 @@ class CountryTableMap extends TableMap */ const ISOALPHA3 = 'country.ISOALPHA3'; + /** + * the column name for the BY_DEFAULT field + */ + const BY_DEFAULT = 'country.BY_DEFAULT'; + /** * the column name for the CREATED_AT field */ @@ -125,12 +130,12 @@ class CountryTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'byDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::BY_DEFAULT, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'by_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -140,12 +145,12 @@ class CountryTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::CREATED_AT => 5, CountryTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::BY_DEFAULT => 5, CountryTableMap::CREATED_AT => 6, CountryTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -169,6 +174,7 @@ class CountryTableMap extends TableMap $this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null); $this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null); $this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null); + $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -351,6 +357,7 @@ class CountryTableMap extends TableMap $criteria->addSelectColumn(CountryTableMap::ISOCODE); $criteria->addSelectColumn(CountryTableMap::ISOALPHA2); $criteria->addSelectColumn(CountryTableMap::ISOALPHA3); + $criteria->addSelectColumn(CountryTableMap::BY_DEFAULT); $criteria->addSelectColumn(CountryTableMap::CREATED_AT); $criteria->addSelectColumn(CountryTableMap::UPDATED_AT); } else { @@ -359,6 +366,7 @@ class CountryTableMap extends TableMap $criteria->addSelectColumn($alias . '.ISOCODE'); $criteria->addSelectColumn($alias . '.ISOALPHA2'); $criteria->addSelectColumn($alias . '.ISOALPHA3'); + $criteria->addSelectColumn($alias . '.BY_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php index b37a6b30a..9c0e65296 100644 --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -184,7 +184,7 @@ class CurrencyTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders'); + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'Carts'); $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'CASCADE', null, 'ProductPrices'); $this->addRelation('CurrencyI18n', '\\Thelia\\Model\\CurrencyI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CurrencyI18ns'); @@ -210,7 +210,6 @@ class CurrencyTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderTableMap::clearInstancePool(); ProductPriceTableMap::clearInstancePool(); CurrencyI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index b23f4d6b0..4dd1c3e7d 100644 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -57,7 +57,7 @@ class CustomerTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 14; + const NUM_COLUMNS = 16; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CustomerTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 14; + const NUM_HYDRATE_COLUMNS = 16; /** * the column name for the ID field @@ -129,6 +129,16 @@ class CustomerTableMap extends TableMap */ const DISCOUNT = 'customer.DISCOUNT'; + /** + * the column name for the REMEMBER_ME_TOKEN field + */ + const REMEMBER_ME_TOKEN = 'customer.REMEMBER_ME_TOKEN'; + + /** + * the column name for the REMEMBER_ME_SERIAL field + */ + const REMEMBER_ME_SERIAL = 'customer.REMEMBER_ME_SERIAL'; + /** * the column name for the CREATED_AT field */ @@ -151,12 +161,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'TitleId', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'titleId', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::TITLE_ID, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'TITLE_ID', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'title_id', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id', 'Ref', 'TitleId', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'RememberMeToken', 'RememberMeSerial', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'titleId', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'rememberMeToken', 'rememberMeSerial', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::TITLE_ID, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::REMEMBER_ME_TOKEN, CustomerTableMap::REMEMBER_ME_SERIAL, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'TITLE_ID', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'REMEMBER_ME_TOKEN', 'REMEMBER_ME_SERIAL', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'title_id', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'remember_me_token', 'remember_me_serial', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) ); /** @@ -166,12 +176,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'TitleId' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Email' => 5, 'Password' => 6, 'Algo' => 7, 'Reseller' => 8, 'Lang' => 9, 'Sponsor' => 10, 'Discount' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'titleId' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'createdAt' => 12, 'updatedAt' => 13, ), - self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::TITLE_ID => 2, CustomerTableMap::FIRSTNAME => 3, CustomerTableMap::LASTNAME => 4, CustomerTableMap::EMAIL => 5, CustomerTableMap::PASSWORD => 6, CustomerTableMap::ALGO => 7, CustomerTableMap::RESELLER => 8, CustomerTableMap::LANG => 9, CustomerTableMap::SPONSOR => 10, CustomerTableMap::DISCOUNT => 11, CustomerTableMap::CREATED_AT => 12, CustomerTableMap::UPDATED_AT => 13, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'TITLE_ID' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'EMAIL' => 5, 'PASSWORD' => 6, 'ALGO' => 7, 'RESELLER' => 8, 'LANG' => 9, 'SPONSOR' => 10, 'DISCOUNT' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'title_id' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'created_at' => 12, 'updated_at' => 13, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'TitleId' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Email' => 5, 'Password' => 6, 'Algo' => 7, 'Reseller' => 8, 'Lang' => 9, 'Sponsor' => 10, 'Discount' => 11, 'RememberMeToken' => 12, 'RememberMeSerial' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'titleId' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'rememberMeToken' => 12, 'rememberMeSerial' => 13, 'createdAt' => 14, 'updatedAt' => 15, ), + self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::TITLE_ID => 2, CustomerTableMap::FIRSTNAME => 3, CustomerTableMap::LASTNAME => 4, CustomerTableMap::EMAIL => 5, CustomerTableMap::PASSWORD => 6, CustomerTableMap::ALGO => 7, CustomerTableMap::RESELLER => 8, CustomerTableMap::LANG => 9, CustomerTableMap::SPONSOR => 10, CustomerTableMap::DISCOUNT => 11, CustomerTableMap::REMEMBER_ME_TOKEN => 12, CustomerTableMap::REMEMBER_ME_SERIAL => 13, CustomerTableMap::CREATED_AT => 14, CustomerTableMap::UPDATED_AT => 15, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'TITLE_ID' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'EMAIL' => 5, 'PASSWORD' => 6, 'ALGO' => 7, 'RESELLER' => 8, 'LANG' => 9, 'SPONSOR' => 10, 'DISCOUNT' => 11, 'REMEMBER_ME_TOKEN' => 12, 'REMEMBER_ME_SERIAL' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'title_id' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'remember_me_token' => 12, 'remember_me_serial' => 13, 'created_at' => 14, 'updated_at' => 15, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) ); /** @@ -202,6 +212,8 @@ class CustomerTableMap extends TableMap $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null); $this->addColumn('SPONSOR', 'Sponsor', 'VARCHAR', false, 50, null); $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, null); + $this->addColumn('REMEMBER_ME_TOKEN', 'RememberMeToken', 'VARCHAR', false, 255, null); + $this->addColumn('REMEMBER_ME_SERIAL', 'RememberMeSerial', 'VARCHAR', false, 255, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -213,7 +225,7 @@ class CustomerTableMap extends TableMap { $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses'); - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders'); + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), null, null, 'Carts'); } // buildRelations() @@ -237,7 +249,6 @@ class CustomerTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AddressTableMap::clearInstancePool(); - OrderTableMap::clearInstancePool(); } /** @@ -390,6 +401,8 @@ class CustomerTableMap extends TableMap $criteria->addSelectColumn(CustomerTableMap::LANG); $criteria->addSelectColumn(CustomerTableMap::SPONSOR); $criteria->addSelectColumn(CustomerTableMap::DISCOUNT); + $criteria->addSelectColumn(CustomerTableMap::REMEMBER_ME_TOKEN); + $criteria->addSelectColumn(CustomerTableMap::REMEMBER_ME_SERIAL); $criteria->addSelectColumn(CustomerTableMap::CREATED_AT); $criteria->addSelectColumn(CustomerTableMap::UPDATED_AT); } else { @@ -405,6 +418,8 @@ class CustomerTableMap extends TableMap $criteria->addSelectColumn($alias . '.LANG'); $criteria->addSelectColumn($alias . '.SPONSOR'); $criteria->addSelectColumn($alias . '.DISCOUNT'); + $criteria->addSelectColumn($alias . '.REMEMBER_ME_TOKEN'); + $criteria->addSelectColumn($alias . '.REMEMBER_ME_SERIAL'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 76c2fe724..067a242a3 100644 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -168,9 +168,9 @@ class FeatureTableMap extends TableMap { $this->addRelation('FeatureAv', '\\Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureAvs'); $this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts'); - $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); + $this->addRelation('FeatureTemplate', '\\Thelia\\Model\\FeatureTemplate', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureTemplates'); $this->addRelation('FeatureI18n', '\\Thelia\\Model\\FeatureI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FeatureI18ns'); - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories'); + $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_MANY, array(), null, null, 'Templates'); } // buildRelations() /** @@ -195,7 +195,7 @@ class FeatureTableMap extends TableMap // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. FeatureAvTableMap::clearInstancePool(); FeatureProductTableMap::clearInstancePool(); - FeatureCategoryTableMap::clearInstancePool(); + FeatureTemplateTableMap::clearInstancePool(); FeatureI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php similarity index 73% rename from core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php rename to core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php index 3e20805b6..abb1a98b7 100644 --- a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\FeatureCategory; -use Thelia\Model\FeatureCategoryQuery; +use Thelia\Model\FeatureTemplate; +use Thelia\Model\FeatureTemplateQuery; /** - * This class defines the structure of the 'feature_category' table. + * This class defines the structure of the 'feature_template' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\FeatureCategoryQuery; * (i.e. if it's a text column type). * */ -class FeatureCategoryTableMap extends TableMap +class FeatureTemplateTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.FeatureCategoryTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.FeatureTemplateTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class FeatureCategoryTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'feature_category'; + const TABLE_NAME = 'feature_template'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\FeatureCategory'; + const OM_CLASS = '\\Thelia\\Model\\FeatureTemplate'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.FeatureCategory'; + const CLASS_DEFAULT = 'Thelia.Model.FeatureTemplate'; /** * The total number of columns @@ -72,27 +72,27 @@ class FeatureCategoryTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'feature_category.ID'; + const ID = 'feature_template.ID'; /** * the column name for the FEATURE_ID field */ - const FEATURE_ID = 'feature_category.FEATURE_ID'; + const FEATURE_ID = 'feature_template.FEATURE_ID'; /** - * the column name for the CATEGORY_ID field + * the column name for the TEMPLATE_ID field */ - const CATEGORY_ID = 'feature_category.CATEGORY_ID'; + const TEMPLATE_ID = 'feature_template.TEMPLATE_ID'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'feature_category.CREATED_AT'; + const CREATED_AT = 'feature_template.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'feature_category.UPDATED_AT'; + const UPDATED_AT = 'feature_template.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -106,11 +106,11 @@ class FeatureCategoryTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'FeatureId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'categoryId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID, FeatureCategoryTableMap::FEATURE_ID, FeatureCategoryTableMap::CATEGORY_ID, FeatureCategoryTableMap::CREATED_AT, FeatureCategoryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'feature_id', 'category_id', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class FeatureCategoryTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'CategoryId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'categoryId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID => 0, FeatureCategoryTableMap::FEATURE_ID => 1, FeatureCategoryTableMap::CATEGORY_ID => 2, FeatureCategoryTableMap::CREATED_AT => 3, FeatureCategoryTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'CATEGORY_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'category_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::CREATED_AT => 3, FeatureTemplateTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -139,16 +139,16 @@ class FeatureCategoryTableMap extends TableMap public function initialize() { // attributes - $this->setName('feature_category'); - $this->setPhpName('FeatureCategory'); - $this->setClassName('\\Thelia\\Model\\FeatureCategory'); + $this->setName('feature_template'); + $this->setPhpName('FeatureTemplate'); + $this->setClassName('\\Thelia\\Model\\FeatureTemplate'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); $this->setIsCrossRef(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); + $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -158,8 +158,8 @@ class FeatureCategoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), null, null); } // buildRelations() /** @@ -231,7 +231,7 @@ class FeatureCategoryTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? FeatureCategoryTableMap::CLASS_DEFAULT : FeatureCategoryTableMap::OM_CLASS; + return $withPrefix ? FeatureTemplateTableMap::CLASS_DEFAULT : FeatureTemplateTableMap::OM_CLASS; } /** @@ -245,21 +245,21 @@ class FeatureCategoryTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (FeatureCategory object, last column rank) + * @return array (FeatureTemplate object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool($key))) { + $key = FeatureTemplateTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureTemplateTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = FeatureCategoryTableMap::OM_CLASS; + $cls = FeatureTemplateTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - FeatureCategoryTableMap::addInstanceToPool($obj, $key); + FeatureTemplateTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -282,8 +282,8 @@ class FeatureCategoryTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool($key))) { + $key = FeatureTemplateTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureTemplateTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -292,7 +292,7 @@ class FeatureCategoryTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - FeatureCategoryTableMap::addInstanceToPool($obj, $key); + FeatureTemplateTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -313,15 +313,15 @@ class FeatureCategoryTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(FeatureCategoryTableMap::ID); - $criteria->addSelectColumn(FeatureCategoryTableMap::FEATURE_ID); - $criteria->addSelectColumn(FeatureCategoryTableMap::CATEGORY_ID); - $criteria->addSelectColumn(FeatureCategoryTableMap::CREATED_AT); - $criteria->addSelectColumn(FeatureCategoryTableMap::UPDATED_AT); + $criteria->addSelectColumn(FeatureTemplateTableMap::ID); + $criteria->addSelectColumn(FeatureTemplateTableMap::FEATURE_ID); + $criteria->addSelectColumn(FeatureTemplateTableMap::TEMPLATE_ID); + $criteria->addSelectColumn(FeatureTemplateTableMap::CREATED_AT); + $criteria->addSelectColumn(FeatureTemplateTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.FEATURE_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -336,7 +336,7 @@ class FeatureCategoryTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME)->getTable(FeatureCategoryTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(FeatureTemplateTableMap::DATABASE_NAME)->getTable(FeatureTemplateTableMap::TABLE_NAME); } /** @@ -344,16 +344,16 @@ class FeatureCategoryTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(FeatureCategoryTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureCategoryTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureTemplateTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureTemplateTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureTemplateTableMap()); } } /** - * Performs a DELETE on the database, given a FeatureCategory or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a FeatureTemplate or Criteria object OR a primary key value. * - * @param mixed $values Criteria or FeatureCategory object or primary key or array of primary keys + * @param mixed $values Criteria or FeatureTemplate object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -364,25 +364,25 @@ class FeatureCategoryTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTemplateTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\FeatureCategory) { // it's a model object + } elseif ($values instanceof \Thelia\Model\FeatureTemplate) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(FeatureCategoryTableMap::DATABASE_NAME); - $criteria->add(FeatureCategoryTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(FeatureTemplateTableMap::DATABASE_NAME); + $criteria->add(FeatureTemplateTableMap::ID, (array) $values, Criteria::IN); } - $query = FeatureCategoryQuery::create()->mergeWith($criteria); + $query = FeatureTemplateQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { FeatureCategoryTableMap::clearInstancePool(); + if ($values instanceof Criteria) { FeatureTemplateTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { FeatureCategoryTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { FeatureTemplateTableMap::removeInstanceFromPool($singleval); } } @@ -390,20 +390,20 @@ class FeatureCategoryTableMap extends TableMap } /** - * Deletes all rows from the feature_category table. + * Deletes all rows from the feature_template table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return FeatureCategoryQuery::create()->doDeleteAll($con); + return FeatureTemplateQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a FeatureCategory or Criteria object. + * Performs an INSERT on the database, given a FeatureTemplate or Criteria object. * - * @param mixed $criteria Criteria or FeatureCategory object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or FeatureTemplate object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -412,22 +412,22 @@ class FeatureCategoryTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTemplateTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from FeatureCategory object + $criteria = $criteria->buildCriteria(); // build Criteria from FeatureTemplate object } - if ($criteria->containsKey(FeatureCategoryTableMap::ID) && $criteria->keyContainsValue(FeatureCategoryTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureCategoryTableMap::ID.')'); + if ($criteria->containsKey(FeatureTemplateTableMap::ID) && $criteria->keyContainsValue(FeatureTemplateTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureTemplateTableMap::ID.')'); } // Set the correct dbName - $query = FeatureCategoryQuery::create()->mergeWith($criteria); + $query = FeatureTemplateQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -443,7 +443,7 @@ class FeatureCategoryTableMap extends TableMap return $pk; } -} // FeatureCategoryTableMap +} // FeatureTemplateTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -FeatureCategoryTableMap::buildTableMap(); +FeatureTemplateTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/LangTableMap.php b/core/lib/Thelia/Model/Map/LangTableMap.php index 6d153b869..2e1f23204 100644 --- a/core/lib/Thelia/Model/Map/LangTableMap.php +++ b/core/lib/Thelia/Model/Map/LangTableMap.php @@ -217,6 +217,7 @@ class LangTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'lang_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/ModuleImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleImageI18nTableMap.php new file mode 100644 index 000000000..76c29e11c --- /dev/null +++ b/core/lib/Thelia/Model/Map/ModuleImageI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ModuleImageI18nTableMap::ID, ModuleImageI18nTableMap::LOCALE, ModuleImageI18nTableMap::TITLE, ModuleImageI18nTableMap::DESCRIPTION, ModuleImageI18nTableMap::CHAPO, ModuleImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ModuleImageI18nTableMap::ID => 0, ModuleImageI18nTableMap::LOCALE => 1, ModuleImageI18nTableMap::TITLE => 2, ModuleImageI18nTableMap::DESCRIPTION => 3, ModuleImageI18nTableMap::CHAPO => 4, ModuleImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('module_image_i18n'); + $this->setPhpName('ModuleImageI18n'); + $this->setClassName('\\Thelia\\Model\\ModuleImageI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module_image', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('ModuleImage', '\\Thelia\\Model\\ModuleImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ModuleImageI18n $obj A \Thelia\Model\ModuleImageI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ModuleImageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ModuleImageI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ModuleImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ModuleImageI18nTableMap::CLASS_DEFAULT : ModuleImageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ModuleImageI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ModuleImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ModuleImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ModuleImageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ModuleImageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ModuleImageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ModuleImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ModuleImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ModuleImageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ModuleImageI18nTableMap::ID); + $criteria->addSelectColumn(ModuleImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(ModuleImageI18nTableMap::TITLE); + $criteria->addSelectColumn(ModuleImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ModuleImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(ModuleImageI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ModuleImageI18nTableMap::DATABASE_NAME)->getTable(ModuleImageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ModuleImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ModuleImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ModuleImageI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ModuleImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ModuleImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ModuleImageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ModuleImageI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ModuleImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ModuleImageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ModuleImageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ModuleImageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ModuleImageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the module_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ModuleImageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ModuleImageI18n or Criteria object. + * + * @param mixed $criteria Criteria or ModuleImageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ModuleImageI18n object + } + + + // Set the correct dbName + $query = ModuleImageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ModuleImageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ModuleImageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ModuleImageTableMap.php b/core/lib/Thelia/Model/Map/ModuleImageTableMap.php new file mode 100644 index 000000000..718ac47c5 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ModuleImageTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'ModuleId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'moduleId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ModuleImageTableMap::ID, ModuleImageTableMap::MODULE_ID, ModuleImageTableMap::FILE, ModuleImageTableMap::POSITION, ModuleImageTableMap::CREATED_AT, ModuleImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'MODULE_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'module_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ModuleId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'moduleId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ModuleImageTableMap::ID => 0, ModuleImageTableMap::MODULE_ID => 1, ModuleImageTableMap::FILE => 2, ModuleImageTableMap::POSITION => 3, ModuleImageTableMap::CREATED_AT => 4, ModuleImageTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'MODULE_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'module_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('module_image'); + $this->setPhpName('ModuleImage'); + $this->setClassName('\\Thelia\\Model\\ModuleImage'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('ModuleImageI18n', '\\Thelia\\Model\\ModuleImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleImageI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to module_image * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ModuleImageI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ModuleImageTableMap::CLASS_DEFAULT : ModuleImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ModuleImage object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ModuleImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ModuleImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ModuleImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ModuleImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ModuleImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ModuleImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ModuleImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ModuleImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ModuleImageTableMap::ID); + $criteria->addSelectColumn(ModuleImageTableMap::MODULE_ID); + $criteria->addSelectColumn(ModuleImageTableMap::FILE); + $criteria->addSelectColumn(ModuleImageTableMap::POSITION); + $criteria->addSelectColumn(ModuleImageTableMap::CREATED_AT); + $criteria->addSelectColumn(ModuleImageTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.MODULE_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ModuleImageTableMap::DATABASE_NAME)->getTable(ModuleImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ModuleImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ModuleImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ModuleImageTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ModuleImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ModuleImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ModuleImage) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ModuleImageTableMap::DATABASE_NAME); + $criteria->add(ModuleImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ModuleImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ModuleImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ModuleImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the module_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ModuleImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ModuleImage or Criteria object. + * + * @param mixed $criteria Criteria or ModuleImage object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ModuleImage object + } + + if ($criteria->containsKey(ModuleImageTableMap::ID) && $criteria->keyContainsValue(ModuleImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ModuleImageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ModuleImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ModuleImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ModuleImageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index dae9fda4a..788048e28 100644 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -184,7 +184,11 @@ class ModuleTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('OrderRelatedByPaymentModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'payment_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByPaymentModuleId'); + $this->addRelation('OrderRelatedByDeliveryModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryModuleId'); + $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules'); + $this->addRelation('ModuleImage', '\\Thelia\\Model\\ModuleImage', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'ModuleImages'); $this->addRelation('ModuleI18n', '\\Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns'); } // buildRelations() @@ -208,7 +212,9 @@ class ModuleTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AreaDeliveryModuleTableMap::clearInstancePool(); GroupModuleTableMap::clearInstancePool(); + ModuleImageTableMap::clearInstancePool(); ModuleI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php index 18753e7f0..73b8f798d 100644 --- a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php @@ -211,8 +211,8 @@ class OrderAddressTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('OrderRelatedByAddressInvoice', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressInvoice'); - $this->addRelation('OrderRelatedByAddressDelivery', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressDelivery'); + $this->addRelation('OrderRelatedByInvoiceOrderAddressId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'invoice_order_address_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByInvoiceOrderAddressId'); + $this->addRelation('OrderRelatedByDeliveryOrderAddressId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_order_address_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryOrderAddressId'); } // buildRelations() /** @@ -227,15 +227,6 @@ class OrderAddressTableMap extends TableMap 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), ); } // getBehaviors() - /** - * Method to invalidate the instance pool of all tables related to order_address * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderTableMap::clearInstancePool(); - } /** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. diff --git a/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php new file mode 100644 index 000000000..582bd2305 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php @@ -0,0 +1,503 @@ + array('Id', 'OrderProductId', 'AttributeTitle', 'AttributeChapo', 'AttributeDescription', 'AttributePostscriptumn', 'AttributeAvTitle', 'AttributeAvChapo', 'AttributeAvDescription', 'AttributeAvPostscriptum', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'attributeTitle', 'attributeChapo', 'attributeDescription', 'attributePostscriptumn', 'attributeAvTitle', 'attributeAvChapo', 'attributeAvDescription', 'attributeAvPostscriptum', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, OrderProductAttributeCombinationTableMap::CREATED_AT, OrderProductAttributeCombinationTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'ATTRIBUTE_TITLE', 'ATTRIBUTE_CHAPO', 'ATTRIBUTE_DESCRIPTION', 'ATTRIBUTE_POSTSCRIPTUMN', 'ATTRIBUTE_AV_TITLE', 'ATTRIBUTE_AV_CHAPO', 'ATTRIBUTE_AV_DESCRIPTION', 'ATTRIBUTE_AV_POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'attribute_title', 'attribute_chapo', 'attribute_description', 'attribute_postscriptumn', 'attribute_av_title', 'attribute_av_chapo', 'attribute_av_description', 'attribute_av_postscriptum', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'AttributeTitle' => 2, 'AttributeChapo' => 3, 'AttributeDescription' => 4, 'AttributePostscriptumn' => 5, 'AttributeAvTitle' => 6, 'AttributeAvChapo' => 7, 'AttributeAvDescription' => 8, 'AttributeAvPostscriptum' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'attributeTitle' => 2, 'attributeChapo' => 3, 'attributeDescription' => 4, 'attributePostscriptumn' => 5, 'attributeAvTitle' => 6, 'attributeAvChapo' => 7, 'attributeAvDescription' => 8, 'attributeAvPostscriptum' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), + self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID => 0, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID => 1, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE => 2, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO => 3, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION => 4, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN => 5, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE => 6, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO => 7, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION => 8, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM => 9, OrderProductAttributeCombinationTableMap::CREATED_AT => 10, OrderProductAttributeCombinationTableMap::UPDATED_AT => 11, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'ATTRIBUTE_TITLE' => 2, 'ATTRIBUTE_CHAPO' => 3, 'ATTRIBUTE_DESCRIPTION' => 4, 'ATTRIBUTE_POSTSCRIPTUMN' => 5, 'ATTRIBUTE_AV_TITLE' => 6, 'ATTRIBUTE_AV_CHAPO' => 7, 'ATTRIBUTE_AV_DESCRIPTION' => 8, 'ATTRIBUTE_AV_POSTSCRIPTUM' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'attribute_title' => 2, 'attribute_chapo' => 3, 'attribute_description' => 4, 'attribute_postscriptumn' => 5, 'attribute_av_title' => 6, 'attribute_av_chapo' => 7, 'attribute_av_description' => 8, 'attribute_av_postscriptum' => 9, 'created_at' => 10, 'updated_at' => 11, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('order_product_attribute_combination'); + $this->setPhpName('OrderProductAttributeCombination'); + $this->setClassName('\\Thelia\\Model\\OrderProductAttributeCombination'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); + $this->addColumn('ATTRIBUTE_TITLE', 'AttributeTitle', 'VARCHAR', true, 255, null); + $this->addColumn('ATTRIBUTE_CHAPO', 'AttributeChapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_DESCRIPTION', 'AttributeDescription', 'CLOB', false, null, null); + $this->addColumn('ATTRIBUTE_POSTSCRIPTUMN', 'AttributePostscriptumn', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_AV_TITLE', 'AttributeAvTitle', 'VARCHAR', true, 255, null); + $this->addColumn('ATTRIBUTE_AV_CHAPO', 'AttributeAvChapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_AV_DESCRIPTION', 'AttributeAvDescription', 'CLOB', false, null, null); + $this->addColumn('ATTRIBUTE_AV_POSTSCRIPTUM', 'AttributeAvPostscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderProductAttributeCombinationTableMap::CLASS_DEFAULT : OrderProductAttributeCombinationTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (OrderProductAttributeCombination object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderProductAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderProductAttributeCombinationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderProductAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderProductAttributeCombinationTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderProductAttributeCombinationTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderProductAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderProductAttributeCombinationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + OrderProductAttributeCombinationTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ID); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_TITLE'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_CHAPO'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_POSTSCRIPTUMN'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_TITLE'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_CHAPO'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(OrderProductAttributeCombinationTableMap::DATABASE_NAME)->getTable(OrderProductAttributeCombinationTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderProductAttributeCombinationTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderProductAttributeCombinationTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a OrderProductAttributeCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or OrderProductAttributeCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderProductAttributeCombination) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(OrderProductAttributeCombinationTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderProductAttributeCombinationQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderProductAttributeCombinationTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderProductAttributeCombinationTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_product_attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderProductAttributeCombinationQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderProductAttributeCombination or Criteria object. + * + * @param mixed $criteria Criteria or OrderProductAttributeCombination object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderProductAttributeCombination object + } + + if ($criteria->containsKey(OrderProductAttributeCombinationTableMap::ID) && $criteria->keyContainsValue(OrderProductAttributeCombinationTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductAttributeCombinationTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderProductAttributeCombinationQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderProductAttributeCombinationTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderProductAttributeCombinationTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php index 038d12863..8144f23a7 100644 --- a/core/lib/Thelia/Model/Map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php @@ -57,7 +57,7 @@ class OrderProductTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 12; + const NUM_COLUMNS = 19; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class OrderProductTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 12; + const NUM_HYDRATE_COLUMNS = 19; /** * the column name for the ID field @@ -84,20 +84,30 @@ class OrderProductTableMap extends TableMap */ const PRODUCT_REF = 'order_product.PRODUCT_REF'; + /** + * the column name for the PRODUCT_SALE_ELEMENTS_REF field + */ + const PRODUCT_SALE_ELEMENTS_REF = 'order_product.PRODUCT_SALE_ELEMENTS_REF'; + /** * the column name for the TITLE field */ const TITLE = 'order_product.TITLE'; + /** + * the column name for the CHAPO field + */ + const CHAPO = 'order_product.CHAPO'; + /** * the column name for the DESCRIPTION field */ const DESCRIPTION = 'order_product.DESCRIPTION'; /** - * the column name for the CHAPO field + * the column name for the POSTSCRIPTUM field */ - const CHAPO = 'order_product.CHAPO'; + const POSTSCRIPTUM = 'order_product.POSTSCRIPTUM'; /** * the column name for the QUANTITY field @@ -110,9 +120,34 @@ class OrderProductTableMap extends TableMap const PRICE = 'order_product.PRICE'; /** - * the column name for the TAX field + * the column name for the PROMO_PRICE field */ - const TAX = 'order_product.TAX'; + const PROMO_PRICE = 'order_product.PROMO_PRICE'; + + /** + * the column name for the WAS_NEW field + */ + const WAS_NEW = 'order_product.WAS_NEW'; + + /** + * the column name for the WAS_IN_PROMO field + */ + const WAS_IN_PROMO = 'order_product.WAS_IN_PROMO'; + + /** + * the column name for the WEIGHT field + */ + const WEIGHT = 'order_product.WEIGHT'; + + /** + * the column name for the TAX_RULE_TITLE field + */ + const TAX_RULE_TITLE = 'order_product.TAX_RULE_TITLE'; + + /** + * the column name for the TAX_RULE_DESCRIPTION field + */ + const TAX_RULE_DESCRIPTION = 'order_product.TAX_RULE_DESCRIPTION'; /** * the column name for the PARENT field @@ -141,12 +176,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax_rule_title', 'tax_rule_description', 'parent', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) ); /** @@ -156,12 +191,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'TaxRuleTitle' => 14, 'TaxRuleDescription' => 15, 'Parent' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'taxRuleTitle' => 14, 'taxRuleDescription' => 15, 'parent' => 16, 'createdAt' => 17, 'updatedAt' => 18, ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX_RULE_TITLE => 14, OrderProductTableMap::TAX_RULE_DESCRIPTION => 15, OrderProductTableMap::PARENT => 16, OrderProductTableMap::CREATED_AT => 17, OrderProductTableMap::UPDATED_AT => 18, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX_RULE_TITLE' => 14, 'TAX_RULE_DESCRIPTION' => 15, 'PARENT' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax_rule_title' => 14, 'tax_rule_description' => 15, 'parent' => 16, 'created_at' => 17, 'updated_at' => 18, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) ); /** @@ -182,13 +217,20 @@ class OrderProductTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null); + $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', true, 255, null); + $this->addColumn('PRODUCT_SALE_ELEMENTS_REF', 'ProductSaleElementsRef', 'VARCHAR', true, 255, null); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); - $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null); + $this->addColumn('PROMO_PRICE', 'PromoPrice', 'VARCHAR', false, 45, null); + $this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null); + $this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null); + $this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null); + $this->addColumn('TAX_RULE_TITLE', 'TaxRuleTitle', 'VARCHAR', false, 255, null); + $this->addColumn('TAX_RULE_DESCRIPTION', 'TaxRuleDescription', 'CLOB', false, null, null); $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -200,7 +242,8 @@ class OrderProductTableMap extends TableMap public function buildRelations() { $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderFeature', '\\Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures'); + $this->addRelation('OrderProductAttributeCombination', '\\Thelia\\Model\\OrderProductAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductAttributeCombinations'); + $this->addRelation('OrderProductTax', '\\Thelia\\Model\\OrderProductTax', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductTaxes'); } // buildRelations() /** @@ -222,7 +265,8 @@ class OrderProductTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderFeatureTableMap::clearInstancePool(); + OrderProductAttributeCombinationTableMap::clearInstancePool(); + OrderProductTaxTableMap::clearInstancePool(); } /** @@ -366,12 +410,19 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn(OrderProductTableMap::ID); $criteria->addSelectColumn(OrderProductTableMap::ORDER_ID); $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF); + $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF); $criteria->addSelectColumn(OrderProductTableMap::TITLE); - $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); $criteria->addSelectColumn(OrderProductTableMap::CHAPO); + $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderProductTableMap::POSTSCRIPTUM); $criteria->addSelectColumn(OrderProductTableMap::QUANTITY); $criteria->addSelectColumn(OrderProductTableMap::PRICE); - $criteria->addSelectColumn(OrderProductTableMap::TAX); + $criteria->addSelectColumn(OrderProductTableMap::PROMO_PRICE); + $criteria->addSelectColumn(OrderProductTableMap::WAS_NEW); + $criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO); + $criteria->addSelectColumn(OrderProductTableMap::WEIGHT); + $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_TITLE); + $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_DESCRIPTION); $criteria->addSelectColumn(OrderProductTableMap::PARENT); $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT); $criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT); @@ -379,12 +430,19 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ORDER_ID'); $criteria->addSelectColumn($alias . '.PRODUCT_REF'); + $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_REF'); $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); $criteria->addSelectColumn($alias . '.QUANTITY'); $criteria->addSelectColumn($alias . '.PRICE'); - $criteria->addSelectColumn($alias . '.TAX'); + $criteria->addSelectColumn($alias . '.PROMO_PRICE'); + $criteria->addSelectColumn($alias . '.WAS_NEW'); + $criteria->addSelectColumn($alias . '.WAS_IN_PROMO'); + $criteria->addSelectColumn($alias . '.WEIGHT'); + $criteria->addSelectColumn($alias . '.TAX_RULE_TITLE'); + $criteria->addSelectColumn($alias . '.TAX_RULE_DESCRIPTION'); $criteria->addSelectColumn($alias . '.PARENT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php new file mode 100644 index 000000000..2e8460a6a --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php @@ -0,0 +1,463 @@ + array('Id', 'OrderProductId', 'Title', 'Description', 'Amount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'title', 'description', 'amount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID, OrderProductTaxTableMap::ORDER_PRODUCT_ID, OrderProductTaxTableMap::TITLE, OrderProductTaxTableMap::DESCRIPTION, OrderProductTaxTableMap::AMOUNT, OrderProductTaxTableMap::CREATED_AT, OrderProductTaxTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'TITLE', 'DESCRIPTION', 'AMOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'title', 'description', 'amount', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'Title' => 2, 'Description' => 3, 'Amount' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID => 0, OrderProductTaxTableMap::ORDER_PRODUCT_ID => 1, OrderProductTaxTableMap::TITLE => 2, OrderProductTaxTableMap::DESCRIPTION => 3, OrderProductTaxTableMap::AMOUNT => 4, OrderProductTaxTableMap::CREATED_AT => 5, OrderProductTaxTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'AMOUNT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('order_product_tax'); + $this->setPhpName('OrderProductTax'); + $this->setClassName('\\Thelia\\Model\\OrderProductTax'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderProductTaxTableMap::CLASS_DEFAULT : OrderProductTaxTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (OrderProductTax object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderProductTaxTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderProductTaxTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderProductTaxTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderProductTaxTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderProductTaxTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderProductTaxTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderProductTaxTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + OrderProductTaxTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(OrderProductTaxTableMap::ID); + $criteria->addSelectColumn(OrderProductTaxTableMap::ORDER_PRODUCT_ID); + $criteria->addSelectColumn(OrderProductTaxTableMap::TITLE); + $criteria->addSelectColumn(OrderProductTaxTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderProductTaxTableMap::AMOUNT); + $criteria->addSelectColumn(OrderProductTaxTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderProductTaxTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.AMOUNT'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(OrderProductTaxTableMap::DATABASE_NAME)->getTable(OrderProductTaxTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductTaxTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderProductTaxTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderProductTaxTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a OrderProductTax or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or OrderProductTax object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderProductTax) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderProductTaxTableMap::DATABASE_NAME); + $criteria->add(OrderProductTaxTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderProductTaxQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderProductTaxTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderProductTaxTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_product_tax table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderProductTaxQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderProductTax or Criteria object. + * + * @param mixed $criteria Criteria or OrderProductTax object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderProductTax object + } + + if ($criteria->containsKey(OrderProductTaxTableMap::ID) && $criteria->keyContainsValue(OrderProductTaxTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductTaxTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderProductTaxQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderProductTaxTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderProductTaxTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php index 18406d9aa..f29ed9464 100644 --- a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -150,7 +150,7 @@ class OrderStatusTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); + $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -160,7 +160,7 @@ class OrderStatusTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', 'RESTRICT', 'Orders'); + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); $this->addRelation('OrderStatusI18n', '\\Thelia\\Model\\OrderStatusI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'OrderStatusI18ns'); } // buildRelations() @@ -184,7 +184,6 @@ class OrderStatusTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderTableMap::clearInstancePool(); OrderStatusI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/OrderTableMap.php b/core/lib/Thelia/Model/Map/OrderTableMap.php index 91d9b29de..7daabb665 100644 --- a/core/lib/Thelia/Model/Map/OrderTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderTableMap.php @@ -85,14 +85,14 @@ class OrderTableMap extends TableMap const CUSTOMER_ID = 'order.CUSTOMER_ID'; /** - * the column name for the ADDRESS_INVOICE field + * the column name for the INVOICE_ORDER_ADDRESS_ID field */ - const ADDRESS_INVOICE = 'order.ADDRESS_INVOICE'; + const INVOICE_ORDER_ADDRESS_ID = 'order.INVOICE_ORDER_ADDRESS_ID'; /** - * the column name for the ADDRESS_DELIVERY field + * the column name for the DELIVERY_ORDER_ADDRESS_ID field */ - const ADDRESS_DELIVERY = 'order.ADDRESS_DELIVERY'; + const DELIVERY_ORDER_ADDRESS_ID = 'order.DELIVERY_ORDER_ADDRESS_ID'; /** * the column name for the INVOICE_DATE field @@ -110,19 +110,19 @@ class OrderTableMap extends TableMap const CURRENCY_RATE = 'order.CURRENCY_RATE'; /** - * the column name for the TRANSACTION field + * the column name for the TRANSACTION_REF field */ - const TRANSACTION = 'order.TRANSACTION'; + const TRANSACTION_REF = 'order.TRANSACTION_REF'; /** - * the column name for the DELIVERY_NUM field + * the column name for the DELIVERY_REF field */ - const DELIVERY_NUM = 'order.DELIVERY_NUM'; + const DELIVERY_REF = 'order.DELIVERY_REF'; /** - * the column name for the INVOICE field + * the column name for the INVOICE_REF field */ - const INVOICE = 'order.INVOICE'; + const INVOICE_REF = 'order.INVOICE_REF'; /** * the column name for the POSTAGE field @@ -130,14 +130,14 @@ class OrderTableMap extends TableMap const POSTAGE = 'order.POSTAGE'; /** - * the column name for the PAYMENT field + * the column name for the PAYMENT_MODULE_ID field */ - const PAYMENT = 'order.PAYMENT'; + const PAYMENT_MODULE_ID = 'order.PAYMENT_MODULE_ID'; /** - * the column name for the CARRIER field + * the column name for the DELIVERY_MODULE_ID field */ - const CARRIER = 'order.CARRIER'; + const DELIVERY_MODULE_ID = 'order.DELIVERY_MODULE_ID'; /** * the column name for the STATUS_ID field @@ -145,9 +145,9 @@ class OrderTableMap extends TableMap const STATUS_ID = 'order.STATUS_ID'; /** - * the column name for the LANG field + * the column name for the LANG_ID field */ - const LANG = 'order.LANG'; + const LANG_ID = 'order.LANG_ID'; /** * the column name for the CREATED_AT field @@ -171,11 +171,11 @@ class OrderTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::ADDRESS_INVOICE, OrderTableMap::ADDRESS_DELIVERY, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION, OrderTableMap::DELIVERY_NUM, OrderTableMap::INVOICE, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT, OrderTableMap::CARRIER, OrderTableMap::STATUS_ID, OrderTableMap::LANG, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'ADDRESS_INVOICE', 'ADDRESS_DELIVERY', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION', 'DELIVERY_NUM', 'INVOICE', 'POSTAGE', 'PAYMENT', 'CARRIER', 'STATUS_ID', 'LANG', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'address_invoice', 'address_delivery', 'invoice_date', 'currency_id', 'currency_rate', 'transaction', 'delivery_num', 'invoice', 'postage', 'payment', 'carrier', 'status_id', 'lang', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::INVOICE_ORDER_ADDRESS_ID, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION_REF, OrderTableMap::DELIVERY_REF, OrderTableMap::INVOICE_REF, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT_MODULE_ID, OrderTableMap::DELIVERY_MODULE_ID, OrderTableMap::STATUS_ID, OrderTableMap::LANG_ID, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -186,11 +186,11 @@ class OrderTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'AddressInvoice' => 3, 'AddressDelivery' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'Transaction' => 8, 'DeliveryNum' => 9, 'Invoice' => 10, 'Postage' => 11, 'Payment' => 12, 'Carrier' => 13, 'StatusId' => 14, 'Lang' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'addressInvoice' => 3, 'addressDelivery' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transaction' => 8, 'deliveryNum' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'statusId' => 14, 'lang' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), - self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::ADDRESS_INVOICE => 3, OrderTableMap::ADDRESS_DELIVERY => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION => 8, OrderTableMap::DELIVERY_NUM => 9, OrderTableMap::INVOICE => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT => 12, OrderTableMap::CARRIER => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_INVOICE' => 3, 'ADDRESS_DELIVERY' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION' => 8, 'DELIVERY_NUM' => 9, 'INVOICE' => 10, 'POSTAGE' => 11, 'PAYMENT' => 12, 'CARRIER' => 13, 'STATUS_ID' => 14, 'LANG' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'address_invoice' => 3, 'address_delivery' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction' => 8, 'delivery_num' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'status_id' => 14, 'lang' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Postage' => 11, 'PaymentModuleId' => 12, 'DeliveryModuleId' => 13, 'StatusId' => 14, 'LangId' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'postage' => 11, 'paymentModuleId' => 12, 'deliveryModuleId' => 13, 'statusId' => 14, 'langId' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION_REF => 8, OrderTableMap::DELIVERY_REF => 9, OrderTableMap::INVOICE_REF => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT_MODULE_ID => 12, OrderTableMap::DELIVERY_MODULE_ID => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG_ID => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'POSTAGE' => 11, 'PAYMENT_MODULE_ID' => 12, 'DELIVERY_MODULE_ID' => 13, 'STATUS_ID' => 14, 'LANG_ID' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'postage' => 11, 'payment_module_id' => 12, 'delivery_module_id' => 13, 'status_id' => 14, 'lang_id' => 15, 'created_at' => 16, 'updated_at' => 17, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -211,21 +211,21 @@ class OrderTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null); + $this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null); $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null); - $this->addForeignKey('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', 'order_address', 'ID', false, null, null); - $this->addForeignKey('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', 'order_address', 'ID', false, null, null); + $this->addForeignKey('INVOICE_ORDER_ADDRESS_ID', 'InvoiceOrderAddressId', 'INTEGER', 'order_address', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_ORDER_ADDRESS_ID', 'DeliveryOrderAddressId', 'INTEGER', 'order_address', 'ID', true, null, null); $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null); - $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null); + $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null); $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null); - $this->addColumn('TRANSACTION', 'Transaction', 'VARCHAR', false, 100, null); - $this->addColumn('DELIVERY_NUM', 'DeliveryNum', 'VARCHAR', false, 100, null); - $this->addColumn('INVOICE', 'Invoice', 'VARCHAR', false, 100, null); - $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null); - $this->addColumn('PAYMENT', 'Payment', 'VARCHAR', true, 45, null); - $this->addColumn('CARRIER', 'Carrier', 'VARCHAR', true, 45, null); - $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', false, null, null); - $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null); + $this->addColumn('TRANSACTION_REF', 'TransactionRef', 'VARCHAR', false, 100, null); + $this->addColumn('DELIVERY_REF', 'DeliveryRef', 'VARCHAR', false, 100, null); + $this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 100, null); + $this->addColumn('POSTAGE', 'Postage', 'FLOAT', true, null, null); + $this->addForeignKey('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', true, null, null); + $this->addForeignKey('LANG_ID', 'LangId', 'INTEGER', 'lang', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -235,11 +235,14 @@ class OrderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderAddressRelatedByAddressInvoice', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderAddressRelatedByAddressDelivery', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderStatus', '\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('OrderAddressRelatedByInvoiceOrderAddressId', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('invoice_order_address_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('OrderAddressRelatedByDeliveryOrderAddressId', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('delivery_order_address_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('OrderStatus', '\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('ModuleRelatedByPaymentModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('payment_module_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('ModuleRelatedByDeliveryModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('Lang', '\\Thelia\\Model\\Lang', RelationMap::MANY_TO_ONE, array('lang_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts'); $this->addRelation('CouponOrder', '\\Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'CouponOrders'); } // buildRelations() @@ -408,38 +411,38 @@ class OrderTableMap extends TableMap $criteria->addSelectColumn(OrderTableMap::ID); $criteria->addSelectColumn(OrderTableMap::REF); $criteria->addSelectColumn(OrderTableMap::CUSTOMER_ID); - $criteria->addSelectColumn(OrderTableMap::ADDRESS_INVOICE); - $criteria->addSelectColumn(OrderTableMap::ADDRESS_DELIVERY); + $criteria->addSelectColumn(OrderTableMap::INVOICE_ORDER_ADDRESS_ID); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID); $criteria->addSelectColumn(OrderTableMap::INVOICE_DATE); $criteria->addSelectColumn(OrderTableMap::CURRENCY_ID); $criteria->addSelectColumn(OrderTableMap::CURRENCY_RATE); - $criteria->addSelectColumn(OrderTableMap::TRANSACTION); - $criteria->addSelectColumn(OrderTableMap::DELIVERY_NUM); - $criteria->addSelectColumn(OrderTableMap::INVOICE); + $criteria->addSelectColumn(OrderTableMap::TRANSACTION_REF); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_REF); + $criteria->addSelectColumn(OrderTableMap::INVOICE_REF); $criteria->addSelectColumn(OrderTableMap::POSTAGE); - $criteria->addSelectColumn(OrderTableMap::PAYMENT); - $criteria->addSelectColumn(OrderTableMap::CARRIER); + $criteria->addSelectColumn(OrderTableMap::PAYMENT_MODULE_ID); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_MODULE_ID); $criteria->addSelectColumn(OrderTableMap::STATUS_ID); - $criteria->addSelectColumn(OrderTableMap::LANG); + $criteria->addSelectColumn(OrderTableMap::LANG_ID); $criteria->addSelectColumn(OrderTableMap::CREATED_AT); $criteria->addSelectColumn(OrderTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.REF'); $criteria->addSelectColumn($alias . '.CUSTOMER_ID'); - $criteria->addSelectColumn($alias . '.ADDRESS_INVOICE'); - $criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY'); + $criteria->addSelectColumn($alias . '.INVOICE_ORDER_ADDRESS_ID'); + $criteria->addSelectColumn($alias . '.DELIVERY_ORDER_ADDRESS_ID'); $criteria->addSelectColumn($alias . '.INVOICE_DATE'); $criteria->addSelectColumn($alias . '.CURRENCY_ID'); $criteria->addSelectColumn($alias . '.CURRENCY_RATE'); - $criteria->addSelectColumn($alias . '.TRANSACTION'); - $criteria->addSelectColumn($alias . '.DELIVERY_NUM'); - $criteria->addSelectColumn($alias . '.INVOICE'); + $criteria->addSelectColumn($alias . '.TRANSACTION_REF'); + $criteria->addSelectColumn($alias . '.DELIVERY_REF'); + $criteria->addSelectColumn($alias . '.INVOICE_REF'); $criteria->addSelectColumn($alias . '.POSTAGE'); - $criteria->addSelectColumn($alias . '.PAYMENT'); - $criteria->addSelectColumn($alias . '.CARRIER'); + $criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID'); + $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); $criteria->addSelectColumn($alias . '.STATUS_ID'); - $criteria->addSelectColumn($alias . '.LANG'); + $criteria->addSelectColumn($alias . '.LANG_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php index 6a8361f27..73c87ce9f 100644 --- a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php @@ -57,7 +57,7 @@ class ProductCategoryTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 5; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductCategoryTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 4; + const NUM_HYDRATE_COLUMNS = 5; /** * the column name for the PRODUCT_ID field @@ -79,6 +79,11 @@ class ProductCategoryTableMap extends TableMap */ const CATEGORY_ID = 'product_category.CATEGORY_ID'; + /** + * the column name for the DEFAULT_CATEGORY field + */ + const DEFAULT_CATEGORY = 'product_category.DEFAULT_CATEGORY'; + /** * the column name for the CREATED_AT field */ @@ -101,12 +106,12 @@ class ProductCategoryTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('ProductId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('productId', 'categoryId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID, ProductCategoryTableMap::CATEGORY_ID, ProductCategoryTableMap::CREATED_AT, ProductCategoryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('PRODUCT_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('product_id', 'category_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ProductId', 'CategoryId', 'DefaultCategory', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('productId', 'categoryId', 'defaultCategory', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID, ProductCategoryTableMap::CATEGORY_ID, ProductCategoryTableMap::DEFAULT_CATEGORY, ProductCategoryTableMap::CREATED_AT, ProductCategoryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_ID', 'CATEGORY_ID', 'DEFAULT_CATEGORY', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('product_id', 'category_id', 'default_category', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -116,12 +121,12 @@ class ProductCategoryTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('ProductId' => 0, 'CategoryId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('productId' => 0, 'categoryId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID => 0, ProductCategoryTableMap::CATEGORY_ID => 1, ProductCategoryTableMap::CREATED_AT => 2, ProductCategoryTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('product_id' => 0, 'category_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ProductId' => 0, 'CategoryId' => 1, 'DefaultCategory' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('productId' => 0, 'categoryId' => 1, 'defaultCategory' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID => 0, ProductCategoryTableMap::CATEGORY_ID => 1, ProductCategoryTableMap::DEFAULT_CATEGORY => 2, ProductCategoryTableMap::CREATED_AT => 3, ProductCategoryTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'DEFAULT_CATEGORY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('product_id' => 0, 'category_id' => 1, 'default_category' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -143,6 +148,7 @@ class ProductCategoryTableMap extends TableMap // columns $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null); $this->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER' , 'category', 'ID', true, null, null); + $this->addColumn('DEFAULT_CATEGORY', 'DefaultCategory', 'BOOLEAN', false, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -358,11 +364,13 @@ class ProductCategoryTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(ProductCategoryTableMap::PRODUCT_ID); $criteria->addSelectColumn(ProductCategoryTableMap::CATEGORY_ID); + $criteria->addSelectColumn(ProductCategoryTableMap::DEFAULT_CATEGORY); $criteria->addSelectColumn(ProductCategoryTableMap::CREATED_AT); $criteria->addSelectColumn(ProductCategoryTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.DEFAULT_CATEGORY'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index 9025784bc..fc23ae569 100644 --- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -182,7 +182,7 @@ class ProductSaleElementsTableMap extends TableMap public function buildRelations() { $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'AttributeCombinations'); + $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'CartItems'); $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), 'CASCADE', null, 'ProductPrices'); } // buildRelations() @@ -206,6 +206,7 @@ class ProductSaleElementsTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeCombinationTableMap::clearInstancePool(); ProductPriceTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index f69f6f702..59ac236ac 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -57,7 +57,7 @@ class ProductTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 11; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 11; /** * the column name for the ID field @@ -94,6 +94,11 @@ class ProductTableMap extends TableMap */ const POSITION = 'product.POSITION'; + /** + * the column name for the TEMPLATE_ID field + */ + const TEMPLATE_ID = 'product.TEMPLATE_ID'; + /** * the column name for the CREATED_AT field */ @@ -140,12 +145,12 @@ class ProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'TaxRuleId', 'Ref', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), - self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), - self::TYPE_COLNAME => array(ProductTableMap::ID, ProductTableMap::TAX_RULE_ID, ProductTableMap::REF, ProductTableMap::VISIBLE, ProductTableMap::POSITION, ProductTableMap::CREATED_AT, ProductTableMap::UPDATED_AT, ProductTableMap::VERSION, ProductTableMap::VERSION_CREATED_AT, ProductTableMap::VERSION_CREATED_BY, ), - self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'REF', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), - self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'ref', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'TaxRuleId', 'Ref', 'Visible', 'Position', 'TemplateId', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'visible', 'position', 'templateId', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(ProductTableMap::ID, ProductTableMap::TAX_RULE_ID, ProductTableMap::REF, ProductTableMap::VISIBLE, ProductTableMap::POSITION, ProductTableMap::TEMPLATE_ID, ProductTableMap::CREATED_AT, ProductTableMap::UPDATED_AT, ProductTableMap::VERSION, ProductTableMap::VERSION_CREATED_AT, ProductTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'REF', 'VISIBLE', 'POSITION', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'ref', 'visible', 'position', 'template_id', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -155,12 +160,12 @@ class ProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), - self::TYPE_COLNAME => array(ProductTableMap::ID => 0, ProductTableMap::TAX_RULE_ID => 1, ProductTableMap::REF => 2, ProductTableMap::VISIBLE => 3, ProductTableMap::POSITION => 4, ProductTableMap::CREATED_AT => 5, ProductTableMap::UPDATED_AT => 6, ProductTableMap::VERSION => 7, ProductTableMap::VERSION_CREATED_AT => 8, ProductTableMap::VERSION_CREATED_BY => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Visible' => 3, 'Position' => 4, 'TemplateId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, 'Version' => 8, 'VersionCreatedAt' => 9, 'VersionCreatedBy' => 10, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'templateId' => 5, 'createdAt' => 6, 'updatedAt' => 7, 'version' => 8, 'versionCreatedAt' => 9, 'versionCreatedBy' => 10, ), + self::TYPE_COLNAME => array(ProductTableMap::ID => 0, ProductTableMap::TAX_RULE_ID => 1, ProductTableMap::REF => 2, ProductTableMap::VISIBLE => 3, ProductTableMap::POSITION => 4, ProductTableMap::TEMPLATE_ID => 5, ProductTableMap::CREATED_AT => 6, ProductTableMap::UPDATED_AT => 7, ProductTableMap::VERSION => 8, ProductTableMap::VERSION_CREATED_AT => 9, ProductTableMap::VERSION_CREATED_BY => 10, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'TEMPLATE_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, 'VERSION' => 8, 'VERSION_CREATED_AT' => 9, 'VERSION_CREATED_BY' => 10, ), + self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'template_id' => 5, 'created_at' => 6, 'updated_at' => 7, 'version' => 8, 'version_created_at' => 9, 'version_created_by' => 10, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -184,6 +189,7 @@ class ProductTableMap extends TableMap $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); @@ -197,6 +203,7 @@ class ProductTableMap extends TableMap public function buildRelations() { $this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), null, null); $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts'); $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss'); @@ -388,6 +395,7 @@ class ProductTableMap extends TableMap $criteria->addSelectColumn(ProductTableMap::REF); $criteria->addSelectColumn(ProductTableMap::VISIBLE); $criteria->addSelectColumn(ProductTableMap::POSITION); + $criteria->addSelectColumn(ProductTableMap::TEMPLATE_ID); $criteria->addSelectColumn(ProductTableMap::CREATED_AT); $criteria->addSelectColumn(ProductTableMap::UPDATED_AT); $criteria->addSelectColumn(ProductTableMap::VERSION); @@ -399,6 +407,7 @@ class ProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.REF'); $criteria->addSelectColumn($alias . '.VISIBLE'); $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php index d3e69b16f..14d38a764 100644 --- a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php @@ -57,7 +57,7 @@ class ProductVersionTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 11; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductVersionTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 11; /** * the column name for the ID field @@ -94,6 +94,11 @@ class ProductVersionTableMap extends TableMap */ const POSITION = 'product_version.POSITION'; + /** + * the column name for the TEMPLATE_ID field + */ + const TEMPLATE_ID = 'product_version.TEMPLATE_ID'; + /** * the column name for the CREATED_AT field */ @@ -131,12 +136,12 @@ class ProductVersionTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'TaxRuleId', 'Ref', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), - self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), - self::TYPE_COLNAME => array(ProductVersionTableMap::ID, ProductVersionTableMap::TAX_RULE_ID, ProductVersionTableMap::REF, ProductVersionTableMap::VISIBLE, ProductVersionTableMap::POSITION, ProductVersionTableMap::CREATED_AT, ProductVersionTableMap::UPDATED_AT, ProductVersionTableMap::VERSION, ProductVersionTableMap::VERSION_CREATED_AT, ProductVersionTableMap::VERSION_CREATED_BY, ), - self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'REF', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), - self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'ref', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'TaxRuleId', 'Ref', 'Visible', 'Position', 'TemplateId', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'visible', 'position', 'templateId', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(ProductVersionTableMap::ID, ProductVersionTableMap::TAX_RULE_ID, ProductVersionTableMap::REF, ProductVersionTableMap::VISIBLE, ProductVersionTableMap::POSITION, ProductVersionTableMap::TEMPLATE_ID, ProductVersionTableMap::CREATED_AT, ProductVersionTableMap::UPDATED_AT, ProductVersionTableMap::VERSION, ProductVersionTableMap::VERSION_CREATED_AT, ProductVersionTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'REF', 'VISIBLE', 'POSITION', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'ref', 'visible', 'position', 'template_id', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -146,12 +151,12 @@ class ProductVersionTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), - self::TYPE_COLNAME => array(ProductVersionTableMap::ID => 0, ProductVersionTableMap::TAX_RULE_ID => 1, ProductVersionTableMap::REF => 2, ProductVersionTableMap::VISIBLE => 3, ProductVersionTableMap::POSITION => 4, ProductVersionTableMap::CREATED_AT => 5, ProductVersionTableMap::UPDATED_AT => 6, ProductVersionTableMap::VERSION => 7, ProductVersionTableMap::VERSION_CREATED_AT => 8, ProductVersionTableMap::VERSION_CREATED_BY => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Visible' => 3, 'Position' => 4, 'TemplateId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, 'Version' => 8, 'VersionCreatedAt' => 9, 'VersionCreatedBy' => 10, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'templateId' => 5, 'createdAt' => 6, 'updatedAt' => 7, 'version' => 8, 'versionCreatedAt' => 9, 'versionCreatedBy' => 10, ), + self::TYPE_COLNAME => array(ProductVersionTableMap::ID => 0, ProductVersionTableMap::TAX_RULE_ID => 1, ProductVersionTableMap::REF => 2, ProductVersionTableMap::VISIBLE => 3, ProductVersionTableMap::POSITION => 4, ProductVersionTableMap::TEMPLATE_ID => 5, ProductVersionTableMap::CREATED_AT => 6, ProductVersionTableMap::UPDATED_AT => 7, ProductVersionTableMap::VERSION => 8, ProductVersionTableMap::VERSION_CREATED_AT => 9, ProductVersionTableMap::VERSION_CREATED_BY => 10, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'TEMPLATE_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, 'VERSION' => 8, 'VERSION_CREATED_AT' => 9, 'VERSION_CREATED_BY' => 10, ), + self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'visible' => 3, 'position' => 4, 'template_id' => 5, 'created_at' => 6, 'updated_at' => 7, 'version' => 8, 'version_created_at' => 9, 'version_created_by' => 10, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -175,6 +180,7 @@ class ProductVersionTableMap extends TableMap $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('TEMPLATE_ID', 'TemplateId', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); @@ -257,11 +263,11 @@ class ProductVersionTableMap extends TableMap public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 8 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 8 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -382,6 +388,7 @@ class ProductVersionTableMap extends TableMap $criteria->addSelectColumn(ProductVersionTableMap::REF); $criteria->addSelectColumn(ProductVersionTableMap::VISIBLE); $criteria->addSelectColumn(ProductVersionTableMap::POSITION); + $criteria->addSelectColumn(ProductVersionTableMap::TEMPLATE_ID); $criteria->addSelectColumn(ProductVersionTableMap::CREATED_AT); $criteria->addSelectColumn(ProductVersionTableMap::UPDATED_AT); $criteria->addSelectColumn(ProductVersionTableMap::VERSION); @@ -393,6 +400,7 @@ class ProductVersionTableMap extends TableMap $criteria->addSelectColumn($alias . '.REF'); $criteria->addSelectColumn($alias . '.VISIBLE'); $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index a06230c37..c50a30c90 100644 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -143,7 +143,7 @@ class TaxI18nTableMap extends TableMap $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 012ad2e72..24f8a41d7 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -143,7 +143,7 @@ class TaxRuleI18nTableMap extends TableMap $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php index 391e23b6d..ccc41e013 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -57,7 +57,7 @@ class TaxRuleTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 3; + const NUM_COLUMNS = 4; /** * The number of lazy-loaded columns @@ -67,13 +67,18 @@ class TaxRuleTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 3; + const NUM_HYDRATE_COLUMNS = 4; /** * the column name for the ID field */ const ID = 'tax_rule.ID'; + /** + * the column name for the IS_DEFAULT field + */ + const IS_DEFAULT = 'tax_rule.IS_DEFAULT'; + /** * the column name for the CREATED_AT field */ @@ -105,12 +110,12 @@ class TaxRuleTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, ) + self::TYPE_PHPNAME => array('Id', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::IS_DEFAULT, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'is_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, ) ); /** @@ -120,12 +125,12 @@ class TaxRuleTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ), - self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CREATED_AT => 1, TaxRuleTableMap::UPDATED_AT => 2, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ), - self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ), - self::TYPE_NUM => array(0, 1, 2, ) + self::TYPE_PHPNAME => array('Id' => 0, 'IsDefault' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'isDefault' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::IS_DEFAULT => 1, TaxRuleTableMap::CREATED_AT => 2, TaxRuleTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'IS_DEFAULT' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'is_default' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) ); /** @@ -145,6 +150,7 @@ class TaxRuleTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', true, 1, false); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -323,10 +329,12 @@ class TaxRuleTableMap extends TableMap { if (null === $alias) { $criteria->addSelectColumn(TaxRuleTableMap::ID); + $criteria->addSelectColumn(TaxRuleTableMap::IS_DEFAULT); $criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT); $criteria->addSelectColumn(TaxRuleTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.IS_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/TemplateI18nTableMap.php b/core/lib/Thelia/Model/Map/TemplateI18nTableMap.php new file mode 100644 index 000000000..8db2f4fcf --- /dev/null +++ b/core/lib/Thelia/Model/Map/TemplateI18nTableMap.php @@ -0,0 +1,473 @@ + array('Id', 'Locale', 'Name', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'name', ), + self::TYPE_COLNAME => array(TemplateI18nTableMap::ID, TemplateI18nTableMap::LOCALE, TemplateI18nTableMap::NAME, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'NAME', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'name', ), + self::TYPE_NUM => array(0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Name' => 2, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'name' => 2, ), + self::TYPE_COLNAME => array(TemplateI18nTableMap::ID => 0, TemplateI18nTableMap::LOCALE => 1, TemplateI18nTableMap::NAME => 2, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'NAME' => 2, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'name' => 2, ), + self::TYPE_NUM => array(0, 1, 2, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('template_i18n'); + $this->setPhpName('TemplateI18n'); + $this->setClassName('\\Thelia\\Model\\TemplateI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'template', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('NAME', 'Name', 'VARCHAR', false, 255, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\TemplateI18n $obj A \Thelia\Model\TemplateI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\TemplateI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\TemplateI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\TemplateI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TemplateI18nTableMap::CLASS_DEFAULT : TemplateI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (TemplateI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TemplateI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TemplateI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TemplateI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TemplateI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TemplateI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TemplateI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TemplateI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + TemplateI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(TemplateI18nTableMap::ID); + $criteria->addSelectColumn(TemplateI18nTableMap::LOCALE); + $criteria->addSelectColumn(TemplateI18nTableMap::NAME); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.NAME'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(TemplateI18nTableMap::DATABASE_NAME)->getTable(TemplateI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TemplateI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TemplateI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TemplateI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a TemplateI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or TemplateI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\TemplateI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TemplateI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(TemplateI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(TemplateI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = TemplateI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TemplateI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TemplateI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the template_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TemplateI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a TemplateI18n or Criteria object. + * + * @param mixed $criteria Criteria or TemplateI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from TemplateI18n object + } + + + // Set the correct dbName + $query = TemplateI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TemplateI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TemplateI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/TemplateTableMap.php b/core/lib/Thelia/Model/Map/TemplateTableMap.php new file mode 100644 index 000000000..f1509cbc7 --- /dev/null +++ b/core/lib/Thelia/Model/Map/TemplateTableMap.php @@ -0,0 +1,455 @@ + array('Id', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(TemplateTableMap::ID, TemplateTableMap::CREATED_AT, TemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ), + self::TYPE_COLNAME => array(TemplateTableMap::ID => 0, TemplateTableMap::CREATED_AT => 1, TemplateTableMap::UPDATED_AT => 2, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ), + self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ), + self::TYPE_NUM => array(0, 1, 2, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('template'); + $this->setPhpName('Template'); + $this->setClassName('\\Thelia\\Model\\Template'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), null, null, 'Products'); + $this->addRelation('FeatureTemplate', '\\Thelia\\Model\\FeatureTemplate', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), null, null, 'FeatureTemplates'); + $this->addRelation('AttributeTemplate', '\\Thelia\\Model\\AttributeTemplate', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), null, null, 'AttributeTemplates'); + $this->addRelation('TemplateI18n', '\\Thelia\\Model\\TemplateI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TemplateI18ns'); + $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Features'); + $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Attributes'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'name', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to template * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + TemplateI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TemplateTableMap::CLASS_DEFAULT : TemplateTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (Template object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TemplateTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TemplateTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TemplateTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TemplateTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TemplateTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TemplateTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TemplateTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + TemplateTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(TemplateTableMap::ID); + $criteria->addSelectColumn(TemplateTableMap::CREATED_AT); + $criteria->addSelectColumn(TemplateTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(TemplateTableMap::DATABASE_NAME)->getTable(TemplateTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TemplateTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TemplateTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TemplateTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a Template or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Template object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Template) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TemplateTableMap::DATABASE_NAME); + $criteria->add(TemplateTableMap::ID, (array) $values, Criteria::IN); + } + + $query = TemplateQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TemplateTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TemplateTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the template table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TemplateQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Template or Criteria object. + * + * @param mixed $criteria Criteria or Template object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TemplateTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Template object + } + + if ($criteria->containsKey(TemplateTableMap::ID) && $criteria->keyContainsValue(TemplateTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.TemplateTableMap::ID.')'); + } + + + // Set the correct dbName + $query = TemplateQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TemplateTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TemplateTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/ModuleImage.php b/core/lib/Thelia/Model/ModuleImage.php new file mode 100644 index 000000000..7ea5415bc --- /dev/null +++ b/core/lib/Thelia/Model/ModuleImage.php @@ -0,0 +1,10 @@ +setRef($this->generateRef()); + + $this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this)); + } + + public function generateRef() + { + /* order addresses are unique */ + return uniqid('ORD', true); + } /** * calculate the total amount * - * @TODO create body method + * @param int $tax * - * @return int + * @return int|string|Base\double */ - public function getTotalAmount() + public function getTotalAmount(&$tax = 0) { - return 2; + $amount = 0; + $tax = 0; + + /* browse all products */ + $orderProductIds = array(); + foreach($this->getOrderProducts() as $orderProduct) { + $taxAmount = OrderProductTaxQuery::create() + ->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax') + ->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL) + ->findOne(); + $amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity(); + $tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity(); + } + + return $amount + $tax + $this->getPostage(); // @todo : manage discount + } + + /** + * PROPEL SHOULD FIX IT + * + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; + } + if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_DATE'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_ID'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; + } + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_REF'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_REF'; + } + if ($this->isColumnModified(OrderTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; + } + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::STATUS_ID)) { + $modifiedColumns[':p' . $index++] = 'STATUS_ID'; + } + if ($this->isColumnModified(OrderTableMap::LANG_ID)) { + $modifiedColumns[':p' . $index++] = 'LANG_ID'; + } + if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME); + + if ($db->useQuoteIdentifier()) { + $tableName = $db->quoteIdentifierTable(OrderTableMap::TABLE_NAME); + } else { + $tableName = OrderTableMap::TABLE_NAME; + } + + $sql = sprintf( + 'INSERT INTO %s (%s) VALUES (%s)', + $tableName, + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'REF': + $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); + break; + case 'CUSTOMER_ID': + $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); + break; + case 'INVOICE_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT); + break; + case 'DELIVERY_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT); + break; + case 'INVOICE_DATE': + $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'CURRENCY_ID': + $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); + break; + case 'CURRENCY_RATE': + $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); + break; + case 'TRANSACTION_REF': + $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR); + break; + case 'DELIVERY_REF': + $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR); + break; + case 'INVOICE_REF': + $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR); + break; + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); + break; + case 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); + break; + case 'STATUS_ID': + $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); + break; + case 'LANG_ID': + $stmt->bindValue($identifier, $this->lang_id, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); } } diff --git a/core/lib/Thelia/Model/OrderProduct.php b/core/lib/Thelia/Model/OrderProduct.php old mode 100755 new mode 100644 index 2c0e189aa..235eaf259 --- a/core/lib/Thelia/Model/OrderProduct.php +++ b/core/lib/Thelia/Model/OrderProduct.php @@ -2,8 +2,30 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\OrderProduct as BaseOrderProduct; -class OrderProduct extends BaseOrderProduct { +class OrderProduct extends BaseOrderProduct +{ + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, new OrderEvent($this->getOrder())); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, new OrderEvent($this->getOrder())); + } } diff --git a/core/lib/Thelia/Model/OrderProductAttributeCombination.php b/core/lib/Thelia/Model/OrderProductAttributeCombination.php new file mode 100644 index 000000000..1f9cee13d --- /dev/null +++ b/core/lib/Thelia/Model/OrderProductAttributeCombination.php @@ -0,0 +1,10 @@ +prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (\Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new Order(); + $obj->hydrate($row); + OrderTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + return $obj; + } } // OrderQuery diff --git a/core/lib/Thelia/Model/OrderStatus.php b/core/lib/Thelia/Model/OrderStatus.php index 2927019d0..f78e9c79d 100755 --- a/core/lib/Thelia/Model/OrderStatus.php +++ b/core/lib/Thelia/Model/OrderStatus.php @@ -4,6 +4,11 @@ namespace Thelia\Model; use Thelia\Model\Base\OrderStatus as BaseOrderStatus; -class OrderStatus extends BaseOrderStatus { - +class OrderStatus extends BaseOrderStatus +{ + const CODE_NOT_PAID = "not_paid"; + const CODE_PAID = "paid"; + const CODE_PROCESSED = "processed"; + const CODE_SENT = "sent"; + const CODE_CANCELED = "canceled"; } diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 06c4640d0..cbb6c0051 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -6,19 +6,34 @@ use Propel\Runtime\Exception\PropelException; use Thelia\Model\Base\Product as BaseProduct; use Thelia\Tools\URL; use Thelia\TaxEngine\Calculator; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\ProductEvent; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Propel; +use Thelia\Model\Map\ProductTableMap; class Product extends BaseProduct { - public function getUrl($locale) - { - return URL::getInstance()->retrieve('product', $this->getId(), $locale)->toString(); + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + use \Thelia\Model\Tools\UrlRewritingTrait; + + /** + * {@inheritDoc} + */ + protected function getRewrittenUrlViewName() { + return 'product'; } public function getRealLowestPrice($virtualColumnName = 'real_lowest_price') { try { $amount = $this->getVirtualColumn($virtualColumnName); - } catch(PropelException $e) { + } + catch(PropelException $e) { throw new PropelException("Virtual column `$virtualColumnName` does not exist in Product::getRealLowestPrice"); } @@ -28,6 +43,169 @@ class Product extends BaseProduct public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); + return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()); } + + /** + * @return the current default category ID for this product + */ + public function getDefaultCategoryId() + { + // Find default category + $default_category = ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByDefaultCategory(true) + ->findOne(); + + return $default_category == null ? 0 : $default_category->getCategoryId(); + } + + /** + * Set default category for this product + * + * @param integer $categoryId the new default category id + */ + public function setDefaultCategory($categoryId) + { + // Unset previous category + ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByDefaultCategory(true) + ->find() + ->setByDefault(false) + ->save(); + + // Set new default category + ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByCategoryId($categoryId) + ->find() + ->setByDefault(true) + ->save(); + + return $this; + } + + /** + * Create a new product, along with the default category ID + * + * @param int $defaultCategoryId the default category ID of this product + */ + public function create($defaultCategoryId) { + + $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME); + + $con->beginTransaction(); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this)); + + try { + // Create the product + $this->save($con); + + // Add the default category + $pc = new ProductCategory(); + + $pc + ->setProduct($this) + ->setCategoryId($defaultCategoryId) + ->setDefaultCategory(true) + ->save($con) + ; + + // Set the position + $this->setPosition($this->getNextPosition())->save($con); + + // Create an empty product sale element + $sale_elements = new ProductSaleElements(); + + $sale_elements + ->setProduct($this) + ->setRef($this->getRef()) + ->setPromo(0) + ->setNewness(0) + ->setWeight(0) + ->save($con) + ; + + // Create an empty product price in the default currency + $product_price = new ProductPrice(); + + $product_price + ->setProductSaleElements($sale_elements) + ->setPromoPrice(0) + ->setPrice(0) + ->setCurrency(CurrencyQuery::create()->findOneByByDefault(true)) + ->save($con) + ; + + // Store all the stuff ! + $con->commit(); + + $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this)); + } + catch(\Exception $ex) { + + $con->rollback(); + + throw $ex; + } + } + + /** + * Calculate next position relative to our default category + */ + protected function addCriteriaToPositionQuery($query) + { + // Find products in the same category + $produits = ProductCategoryQuery::create() + ->filterByCategoryId($this->getDefaultCategoryId()) + ->filterByDefaultCategory(true) + ->select('product_id') + ->find(); + + // Filtrer la requete sur ces produits + if ($produits != null) $query->filterById($produits, Criteria::IN); + } + + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEPRODUCT, new ProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEPRODUCT, new ProductEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEPRODUCT, new ProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + RewritingUrlQuery::create() + ->filterByView($this->getRewrittenUrlViewName()) + ->filterByViewId($this->getId()) + ->update(array( + "View" => ConfigQuery::getPassedUrlView() + )); + $this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this)); + } } diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php index 9b007baf1..e07ee2cd6 100644 --- a/core/lib/Thelia/Model/ProductAssociatedContent.php +++ b/core/lib/Thelia/Model/ProductAssociatedContent.php @@ -3,7 +3,65 @@ namespace Thelia\Model; use Thelia\Model\Base\ProductAssociatedContent as BaseProductAssociatedContent; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\ProductAssociatedContentEvent; +use Thelia\Core\Event\TheliaEvents; class ProductAssociatedContent extends BaseProductAssociatedContent { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); + } } diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php index a49c4f11e..53515ff3c 100755 --- a/core/lib/Thelia/Model/ProductDocument.php +++ b/core/lib/Thelia/Model/ProductDocument.php @@ -3,8 +3,27 @@ namespace Thelia\Model; use Thelia\Model\Base\ProductDocument as BaseProductDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class ProductDocument extends BaseProductDocument +class ProductDocument extends BaseProductDocument { + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProduct($this->getProduct()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/ProductI18n.php b/core/lib/Thelia/Model/ProductI18n.php index 7507bceb1..6ec3ac4a3 100755 --- a/core/lib/Thelia/Model/ProductI18n.php +++ b/core/lib/Thelia/Model/ProductI18n.php @@ -2,8 +2,14 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\ProductI18n as BaseProductI18n; class ProductI18n extends BaseProductI18n { + public function postInsert(ConnectionInterface $con = null) + { + $product = $this->getProduct(); + $product->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/ProductImage.php b/core/lib/Thelia/Model/ProductImage.php index 9fe5b78e0..4bf0c40a6 100755 --- a/core/lib/Thelia/Model/ProductImage.php +++ b/core/lib/Thelia/Model/ProductImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\ProductImage as BaseProductImage; +use Propel\Runtime\Connection\ConnectionInterface; - class ProductImage extends BaseProductImage +class ProductImage extends BaseProductImage { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProduct($this->getProduct()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/ProductSaleElements.php b/core/lib/Thelia/Model/ProductSaleElements.php index 184e37d0a..6a95c37f3 100755 --- a/core/lib/Thelia/Model/ProductSaleElements.php +++ b/core/lib/Thelia/Model/ProductSaleElements.php @@ -32,12 +32,12 @@ class ProductSaleElements extends BaseProductSaleElements public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); } public function getTaxedPromoPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); } } diff --git a/core/lib/Thelia/Model/Rewriting.php b/core/lib/Thelia/Model/Rewriting.php deleted file mode 100644 index 8d6f75fab..000000000 --- a/core/lib/Thelia/Model/Rewriting.php +++ /dev/null @@ -1,9 +0,0 @@ -getRedirected()) { + //check if rewriting url alredy exists and put redirect to the new one + RewritingUrlQuery::create() + ->filterByView($this->getView()) + ->filterByViewId($this->getViewId()) + ->filterByViewLocale($this->getViewLocale()) + ->filterByRedirected($this->getId(), Criteria::NOT_IN) + ->update(array( + "Redirected" => $this->getId() + )); + } + } } diff --git a/core/lib/Thelia/Model/TaxRule.php b/core/lib/Thelia/Model/TaxRule.php index 36f80a044..024fd8923 100755 --- a/core/lib/Thelia/Model/TaxRule.php +++ b/core/lib/Thelia/Model/TaxRule.php @@ -3,7 +3,25 @@ namespace Thelia\Model; use Thelia\Model\Base\TaxRule as BaseTaxRule; +use Thelia\TaxEngine\Calculator; +use Thelia\TaxEngine\OrderProductTaxCollection; -class TaxRule extends BaseTaxRule { +class TaxRule extends BaseTaxRule +{ + /** + * @param Country $country + * @param $untaxedAmount + * @param null $askedLocale + * + * @return OrderProductTaxCollection + */ + public function getTaxDetail(Country $country, $untaxedAmount, $askedLocale = null) + { + $taxCalculator = new Calculator(); + $taxCollection = new OrderProductTaxCollection(); + $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale); + + return $taxCollection; + } } diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php index d5ce47546..572500003 100755 --- a/core/lib/Thelia/Model/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/TaxRuleQuery.php @@ -21,13 +21,19 @@ class TaxRuleQuery extends BaseTaxRuleQuery { const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition'; - public function getTaxCalculatorCollection(Product $product, Country $country) + /** + * @param TaxRule $taxRule + * @param Country $country + * + * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection + */ + public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country) { $search = TaxQuery::create() ->filterByTaxRuleCountry( TaxRuleCountryQuery::create() ->filterByCountry($country, Criteria::EQUAL) - ->filterByTaxRuleId($product->getTaxRuleId()) + ->filterByTaxRuleId($taxRule->getId()) ->orderByPosition() ->find() ) diff --git a/core/lib/Thelia/Model/Template.php b/core/lib/Thelia/Model/Template.php new file mode 100644 index 000000000..881187573 --- /dev/null +++ b/core/lib/Thelia/Model/Template.php @@ -0,0 +1,68 @@ +dispatchEvent(TheliaEvents::BEFORE_CREATETEMPLATE, new TemplateEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATETEMPLATE, new TemplateEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATETEMPLATE, new TemplateEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATETEMPLATE, new TemplateEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETETEMPLATE, new TemplateEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETETEMPLATE, new TemplateEvent($this)); + } + +} diff --git a/core/lib/Thelia/Model/TemplateI18n.php b/core/lib/Thelia/Model/TemplateI18n.php new file mode 100644 index 000000000..19e88f692 --- /dev/null +++ b/core/lib/Thelia/Model/TemplateI18n.php @@ -0,0 +1,10 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Model\Tools; + +use Thelia\Core\Event\GenerateRewrittenUrlEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Exception\UrlRewritingException; +use Thelia\Model\RewritingUrlQuery; +use Thelia\Model\RewritingUrl; +use Thelia\Tools\URL; +/** + * A trait for managing Rewriten URLs from model classes + */ +trait UrlRewritingTrait { + + /** + * @returns string the view name of the rewriten object (e.g., 'category', 'product') + */ + protected abstract function getRewrittenUrlViewName(); + + /** + * Get the object URL for the given locale, rewriten if rewriting is enabled. + * + * @param string $locale a valid locale (e.g. en_US) + */ + public function getUrl($locale = null) + { + if(null === $locale) { + $locale = $this->getLocale(); + } + return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString(); + } + + /** + * Generate a rewriten URL from the object title, and store it in the rewriting table + * + * @param string $locale a valid locale (e.g. en_US) + */ + public function generateRewrittenUrl($locale) + { + if ($this->isNew()) { + throw new \RuntimeException(sprintf('Object %s must be saved before generating url', $this->getRewrittenUrlViewName())); + } + // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe + + $this->setLocale($locale); + + $generateEvent = new GenerateRewrittenUrlEvent($this, $locale); + + $this->dispatchEvent(TheliaEvents::GENERATE_REWRITTENURL, $generateEvent); + + + if($generateEvent->isRewritten()) + { + return $generateEvent->getUrl(); + } + + $title = $this->getTitle(); + + if(null == $title) { + throw new \RuntimeException('Impossible to create an url if title is null'); + } + // Replace all weird characters with dashes + $string = preg_replace('/[^\w\-~_\.]+/u', '-', $title); + + // Only allow one dash separator at a time (and make string lowercase) + $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8'); + + $urlFilePart = rtrim($cleanString, '.-~_') . ".html"; + + // TODO : + // check if URL url already exists, and add a numeric suffix, or the like + try{ + $i=0; + while(URL::getInstance()->resolve($urlFilePart)) { + $i++; + $urlFilePart = sprintf("%s-%d.html",$cleanString, $i); + } + } catch (UrlRewritingException $e) { + $rewritingUrl = new RewritingUrl(); + $rewritingUrl->setUrl($urlFilePart) + ->setView($this->getRewrittenUrlViewName()) + ->setViewId($this->getId()) + ->setViewLocale($locale) + ->save() + ; + } + + return $urlFilePart; + + } + + /** + * return the rewriten URL for the given locale + * + * @param string $locale a valid locale (e.g. en_US) + * @return null + */ + public function getRewrittenUrl($locale) + { + $rewritingUrl = RewritingUrlQuery::create() + ->filterByViewLocale($locale) + ->filterByView($this->getRewrittenUrlViewName()) + ->filterByViewId($this->getId()) + ->filterByRedirected(null) + ->findOne() + ; + + if($rewritingUrl) { + $url = $rewritingUrl->getUrl(); + } else { + $url = null; + } + + return $url; + } + + /** + * Set the rewriten URL for the given locale + * + * @param string $locale a valid locale (e.g. en_US) + * @param $url the wanted url + * @return $this + */ + public function setRewrittenUrl($locale, $url) + { + // TODO - code me ! + + return $this; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 9d76e08f3..8efc76e6e 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -25,18 +25,43 @@ namespace Thelia\Module; use Symfony\Component\DependencyInjection\ContainerAware; +use Thelia\Model\ModuleI18nQuery; +use Thelia\Model\Map\ModuleImageTableMap; +use Thelia\Model\ModuleI18n; +use Thelia\Tools\Image; +use Thelia\Exception\ModuleException; +use Thelia\Model\Module; +use Thelia\Model\ModuleImage; +use Thelia\Model\ModuleQuery; abstract class BaseModule extends ContainerAware { + const CLASSIC_MODULE_TYPE = 1; + const DELIVERY_MODULE_TYPE = 2; + const PAYMENT_MODULE_TYPE = 3; + + const IS_ACTIVATED = 1; + const IS_NOT_ACTIVATED = 0; public function __construct() { } - protected function activate() + public function activate() { - + $moduleModel = $this->getModuleModel(); + if($moduleModel->getActivate() == self::IS_NOT_ACTIVATED) { + $moduleModel->setActivate(self::IS_ACTIVATED); + $moduleModel->save(); + try { + $this->afterActivation(); + } catch(\Exception $e) { + $moduleModel->setActivate(self::IS_NOT_ACTIVATED); + $moduleModel->save(); + throw $e; + } + } } public function hasContainer() @@ -53,7 +78,109 @@ abstract class BaseModule extends ContainerAware return $this->container; } + public function setTitle(Module $module, $titles) + { + if(is_array($titles)) { + foreach($titles as $locale => $title) { + $moduleI18n = ModuleI18nQuery::create()->filterById($module->getId())->filterByLocale($locale)->findOne(); + if(null === $moduleI18n) { + $moduleI18n = new ModuleI18n(); + $moduleI18n + ->setId($module->getId()) + ->setLocale($locale) + ->setTitle($title) + ; + $moduleI18n->save(); + } else { + $moduleI18n->setTitle($title); + $moduleI18n->save(); + } + } + } + } + + public function deployImageFolder(Module $module, $folderPath) + { + try { + $directoryBrowser = new \DirectoryIterator($folderPath); + } catch(\UnexpectedValueException $e) { + throw $e; + } + + $con = \Propel\Runtime\Propel::getConnection( + ModuleImageTableMap::DATABASE_NAME + ); + + /* browse the directory */ + $imagePosition = 1; + foreach($directoryBrowser as $directoryContent) { + /* is it a file ? */ + if ($directoryContent->isFile()) { + + $fileName = $directoryContent->getFilename(); + $filePath = $directoryContent->getPathName(); + + /* is it a picture ? */ + if( Image::isImage($filePath) ) { + + $con->beginTransaction(); + + $image = new ModuleImage(); + $image->setModuleId($module->getId()); + $image->setPosition($imagePosition); + $image->save($con); + + $imageDirectory = sprintf("%s/../../../../local/media/images/module", __DIR__); + $imageFileName = sprintf("%s-%d-%s", $module->getCode(), $image->getId(), $fileName); + + $increment = 0; + while(file_exists($imageDirectory . '/' . $imageFileName)) { + $imageFileName = sprintf("%s-%d-%d-%s", $module->getCode(), $image->getId(), $increment, $fileName); + $increment++; + } + + $imagePath = sprintf('%s/%s', $imageDirectory, $imageFileName); + + if (! is_dir($imageDirectory)) { + if(! @mkdir($imageDirectory, 0777, true)) { + $con->rollBack(); + throw new ModuleException(sprintf("Cannot create directory : %s", $imageDirectory), ModuleException::CODE_NOT_FOUND); + } + } + + if(! @copy($filePath, $imagePath)) { + $con->rollBack(); + throw new ModuleException(sprintf("Cannot copy file : %s to : %s", $filePath, $imagePath), ModuleException::CODE_NOT_FOUND); + } + + $image->setFile($imageFileName); + $image->save($con); + + $con->commit(); + $imagePosition++; + } + } + } + } + + /** + * @return Module + * @throws \Thelia\Exception\ModuleException + */ + public function getModuleModel() + { + $moduleModel = ModuleQuery::create()->findOneByCode($this->getCode()); + + if(null === $moduleModel) { + throw new ModuleException(sprintf("Module Code `%s` not found", $this->getCode()), ModuleException::CODE_NOT_FOUND); + } + + return $moduleModel; + } + + abstract public function getCode(); abstract public function install(); + abstract public function afterActivation(); abstract public function destroy(); } diff --git a/core/lib/Thelia/Module/DeliveryModuleInterface.php b/core/lib/Thelia/Module/DeliveryModuleInterface.php index ba218ac4d..17b000d4f 100644 --- a/core/lib/Thelia/Module/DeliveryModuleInterface.php +++ b/core/lib/Thelia/Module/DeliveryModuleInterface.php @@ -23,13 +23,16 @@ namespace Thelia\Module; +use Thelia\Model\Country; + interface DeliveryModuleInterface extends BaseModuleInterface { /** - * * calculate and return delivery price * + * @param Country $country + * * @return mixed */ - public function calculate($country = null); + public function getPostage(Country $country); } diff --git a/core/lib/Thelia/Module/PaymentModuleInterface.php b/core/lib/Thelia/Module/PaymentModuleInterface.php new file mode 100644 index 000000000..d864ae50a --- /dev/null +++ b/core/lib/Thelia/Module/PaymentModuleInterface.php @@ -0,0 +1,34 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Module; + +use Thelia\Model\Country; + +interface PaymentModuleInterface extends BaseModuleInterface +{ + /** + * @return mixed + */ + public function pay(); +} diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php index b5a2f995e..8039dec39 100755 --- a/core/lib/Thelia/TaxEngine/Calculator.php +++ b/core/lib/Thelia/TaxEngine/Calculator.php @@ -24,8 +24,11 @@ namespace Thelia\TaxEngine; use Thelia\Exception\TaxEngineException; use Thelia\Model\Country; +use Thelia\Model\OrderProductTax; use Thelia\Model\Product; +use Thelia\Model\TaxRule; use Thelia\Model\TaxRuleQuery; +use Thelia\Tools\I18n; /** * Class Calculator @@ -68,14 +71,34 @@ class Calculator $this->product = $product; $this->country = $country; - $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country); + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product->getTaxRule(), $country); return $this; } - public function getTaxAmountFromUntaxedPrice($untaxedPrice) + public function loadTaxRule(TaxRule $taxRule, Country $country) { - return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice; + $this->product = null; + $this->country = null; + $this->taxRulesCollection = null; + + if($taxRule->getId() === null) { + throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); + } + if($country->getId() === null) { + throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); + } + + $this->country = $country; + + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); + + return $this; + } + + public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null) + { + return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice; } public function getTaxAmountFromTaxedPrice($taxedPrice) @@ -83,7 +106,15 @@ class Calculator return $taxedPrice - $this->getUntaxedPrice($taxedPrice); } - public function getTaxedPrice($untaxedPrice) + /** + * @param $untaxedPrice + * @param null $taxCollection returns OrderProductTaxCollection + * @param null $askedLocale + * + * @return int + * @throws \Thelia\Exception\TaxEngineException + */ + public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null) { if(null === $this->taxRulesCollection) { throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION); @@ -97,6 +128,9 @@ class Calculator $currentPosition = 1; $currentTax = 0; + if(null !== $taxCollection) { + $taxCollection = new OrderProductTaxCollection(); + } foreach($this->taxRulesCollection as $taxRule) { $position = (int)$taxRule->getTaxRuleCountryPosition(); @@ -109,7 +143,17 @@ class Calculator $currentPosition = $position; } - $currentTax += $taxType->calculate($taxedPrice); + $taxAmount = round($taxType->calculate($taxedPrice), 2); + $currentTax += $taxAmount; + + if(null !== $taxCollection) { + $taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId()); + $orderProductTax = new OrderProductTax(); + $orderProductTax->setTitle($taxI18n->getTitle()); + $orderProductTax->setDescription($taxI18n->getDescription()); + $orderProductTax->setAmount($taxAmount); + $taxCollection->addTax($orderProductTax); + } } $taxedPrice += $currentTax; diff --git a/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php new file mode 100755 index 000000000..5c4ac2022 --- /dev/null +++ b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php @@ -0,0 +1,126 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\TaxEngine; + +use Thelia\Model\OrderProductTax; + +/** + * + * @author Etienne Roudeix + * + */ +class OrderProductTaxCollection implements \Iterator +{ + private $position; + protected $taxes = array(); + + public function __construct() + { + foreach (func_get_args() as $tax) { + $this->addTax($tax); + } + } + + public function isEmpty() + { + return count($this->taxes) == 0; + } + + /** + * @param OrderProductTax $tax + * + * @return OrderProductTaxCollection + */ + public function addTax(OrderProductTax $tax) + { + $this->taxes[] = $tax; + + return $this; + } + + public function getCount() + { + return count($this->taxes); + } + + /** + * (PHP 5 >= 5.0.0)
+ * Return the current element + * @link http://php.net/manual/en/iterator.current.php + * @return OrderProductTax + */ + public function current() + { + return $this->taxes[$this->position]; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Move forward to next element + * @link http://php.net/manual/en/iterator.next.php + * @return void Any returned value is ignored. + */ + public function next() + { + $this->position++; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Return the key of the current element + * @link http://php.net/manual/en/iterator.key.php + * @return mixed scalar on success, or null on failure. + */ + public function key() + { + return $this->position; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Checks if current position is valid + * @link http://php.net/manual/en/iterator.valid.php + * @return boolean The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. + */ + public function valid() + { + return isset($this->taxes[$this->position]); + } + + /** + * (PHP 5 >= 5.0.0)
+ * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. + */ + public function rewind() + { + $this->position = 0; + } + + public function getKey($key) + { + return isset($this->taxes[$key]) ? $this->taxes[$key] : null; + } +} diff --git a/core/lib/Thelia/Tests/Action/DocumentTest.php b/core/lib/Thelia/Tests/Action/DocumentTest.php new file mode 100644 index 000000000..39aece1f4 --- /dev/null +++ b/core/lib/Thelia/Tests/Action/DocumentTest.php @@ -0,0 +1,248 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action\DocumentTest; + +use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\HttpFoundation\Session\Session; + +use Thelia\Action\Document; +use Thelia\Core\Event\DocumentEvent; +use Thelia\Model\ConfigQuery; + +/** + * Class DocumentTest + * + * @package Thelia\Tests\Action\DocumentTest + */ +class DocumentTest extends \Thelia\Tests\TestCaseWithURLToolSetup +{ + protected $request; + + protected $session; + + public function getContainer() + { + $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); + + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + + $container->set("event_dispatcher", $dispatcher); + + $request = new Request(); + $request->setSession($this->session); + + $container->set("request", $request); + + return $container; + } + + public function setUp() + { + $this->session = new Session(new MockArraySessionStorage()); + $this->request = new Request(); + + $this->request->setSession($this->session); + + // mock cache configuration. + $config = ConfigQuery::create()->filterByName('document_cache_dir_from_web_root')->findOne(); + + if ($config != null) { + $this->cache_dir_from_web_root = $config->getValue(); + + $config->setValue(__DIR__."/assets/documents/cache"); + + $config->setValue($this->cache_dir_from_web_root)->save(); + } + } + + public static function setUpBeforeClass() + { + $dir = THELIA_WEB_DIR."/cache/tests"; + if ($dh = @opendir($dir)) { + while ($file = readdir($dh)) { + if ($file == '.' || $file == '..') continue; + + unlink(sprintf("%s/%s", $dir, $file)); + } + + closedir($dh); + } + } + + public function tearDown() + { + // restore cache configuration. + $config = ConfigQuery::create()->filterByName('document_cache_dir_from_web_root')->findOne(); + + if ($config != null) { + $config->setValue($this->cache_dir_from_web_root)->save(); + } + } + + /** + * + * Documentevent is empty, mandatory parameters not specified. + * + * @expectedException \InvalidArgumentException + */ + public function testProcessEmptyDocumentEvent() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $document->processDocument($event); + } + + /** + * + * Try to process a non-existent file + * + * @expectedException \InvalidArgumentException + */ + public function testProcessNonExistentDocument() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $event->setCacheFilepath("blablabla.txt"); + $event->setCacheSubdirectory("tests"); + + $document->processDocument($event); + } + + /** + * + * Try to process a file outside of the cache + * + * @expectedException \InvalidArgumentException + */ + public function testProcessDocumentOutsideValidPath() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $event->setCacheFilepath("blablabla.pdf"); + $event->setCacheSubdirectory("../../../"); + + $document->processDocument($event); + } + + /** + * No operation done on source file -> copie ! + */ + public function testProcessDocumentCopy() + { + $event = new DocumentEvent($this->request); + + $event->setSourceFilepath(__DIR__."/assets/documents/sources/test-document-1.txt"); + $event->setCacheSubdirectory("tests"); + + $document = new Document($this->getContainer()); + + // mock cache configuration. + $config = ConfigQuery::create()->filterByName('original_document_delivery_mode')->findOne(); + + if ($config != null) { + $oldval = $config->getValue(); + $config->setValue('copy')->save(); + } + + $document->processDocument($event); + + if ($config != null) $config->setValue($oldval)->save(); + + $imgdir = ConfigQuery::read('document_cache_dir_from_web_root'); + + $this->assertFileExists(THELIA_WEB_DIR."/$imgdir/tests/test-document-1.txt"); + } + + /** + * No operation done on source file -> link ! + */ + public function testProcessDocumentSymlink() + { + $event = new DocumentEvent($this->request); + + $event->setSourceFilepath(__DIR__."/assets/documents/sources/test-document-2.txt"); + $event->setCacheSubdirectory("tests"); + + $document = new Document($this->getContainer()); + + // mock cache configuration. + $config = ConfigQuery::create()->filterByName('original_document_delivery_mode')->findOne(); + + if ($config != null) { + $oldval = $config->getValue(); + $config->setValue('symlink')->save(); + } + + $document->processDocument($event); + + if ($config != null) $config->setValue($oldval)->save(); + + $imgdir = ConfigQuery::read('document_cache_dir_from_web_root'); + + $this->assertFileExists(THELIA_WEB_DIR."/$imgdir/tests/test-document-2.txt"); + } + + public function testClearTestsCache() + { + $event = new DocumentEvent($this->request); + + $event->setCacheSubdirectory('tests'); + + $document = new Document($this->getContainer()); + + $document->clearCache($event); + } + + public function testClearWholeCache() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $document->clearCache($event); + } + + /** + * Try to clear directory ouside of the cache + * + * @expectedException \InvalidArgumentException + */ + public function testClearUnallowedPathCache() + { + $event = new DocumentEvent($this->request); + + $event->setCacheSubdirectory('../../../..'); + + $document = new Document($this->getContainer()); + + $document->clearCache($event); + } +} diff --git a/core/lib/Thelia/Tests/Action/OrderTest.php b/core/lib/Thelia/Tests/Action/OrderTest.php new file mode 100644 index 000000000..3802b362f --- /dev/null +++ b/core/lib/Thelia/Tests/Action/OrderTest.php @@ -0,0 +1,353 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\HttpFoundation\Session\Session; +use Thelia\Core\Security\SecurityContext; +use Thelia\Model\AddressQuery; +use Thelia\Model\Base\OrderProductQuery; +use Thelia\Model\OrderStatus; +use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Model\Cart; +use Thelia\Model\CartItem; +use Thelia\Model\CurrencyQuery; +use Thelia\Model\CustomerQuery; +use Thelia\Model\ModuleQuery; +use Thelia\Model\Order as OrderModel; +use Thelia\Model\Customer as CustomerModel; +use Thelia\Action\Order; +use Thelia\Model\ProductQuery; +use Thelia\Module\BaseModule; + +/** + * Class CustomerTest + * @package Thelia\Tests\Action + * @author Etienne Roudeix + */ +class OrderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ContainerBuilder $container + */ + protected $container; + + /** + * @var Order $orderAction + */ + protected $orderAction; + + /** + * @var OrderEvent $orderEvent + */ + protected $orderEvent; + + /** + * @var CustomerModel $customer + */ + protected $customer; + + /** + * @var Cart $customer + */ + protected $cart; + + /** + * @var CartItem[] + */ + protected $cartItems; + + public function setUp() + { + $container = new ContainerBuilder(); + + $session = new Session(new MockArraySessionStorage()); + $request = new Request(); + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + + $request->setSession($session); + + $container->set("event_dispatcher", $dispatcher); + $container->set('request', $request); + $container->set('thelia.securityContext', new SecurityContext($request)); + + $this->container = $container; + + $this->orderEvent = new OrderEvent(new OrderModel()); + + $this->orderAction = new Order($this->container); + + /* load customer */ + $this->customer = $this->loadCustomer(); + if(null === $this->customer) { + return; + } + + /* fill cart */ + $this->cart = $this->fillCart(); + + } + + public function loadCustomer() + { + $customer = CustomerQuery::create()->findOne(); + if(null === $customer) { + return null; + } + + $this->container->get('thelia.securityContext')->setCustomerUser($customer); + + return $customer; + } + + public function fillCart() + { + $currency = CurrencyQuery::create()->findOne(); + + //create a fake cart in database; + $cart = new Cart(); + $cart->setToken(uniqid("createorder", true)) + ->setCustomer($this->customer) + ->setCurrency($currency) + ->save(); + + /* add 3 items */ + $productList = array(); + for($i=0; $i<3; $i++) { + $pse = ProductSaleElementsQuery::create() + ->filterByProduct( + ProductQuery::create() + ->filterByVisible(1) + ->filterById($productList, Criteria::NOT_IN) + ->find() + ) + ->filterByQuantity(5, Criteria::GREATER_EQUAL) + ->joinProductPrice('pp', Criteria::INNER_JOIN) + ->addJoinCondition('pp', 'currency_id = ?', $currency->getId(), null, \PDO::PARAM_INT) + ->withColumn('`pp`.price', 'price_PRICE') + ->withColumn('`pp`.promo_price', 'price_PROMO_PRICE') + ->findOne(); + + $productList[] = $pse->getProductId(); + + $cartItem = new CartItem(); + $cartItem + ->setCart($cart) + ->setProduct($pse->getProduct()) + ->setProductSaleElements($pse) + ->setQuantity($i) + ->setPrice($pse->getPrice()) + ->setPromoPrice($pse->getPromoPrice()) + ->setPromo($pse->getPromo()) + ->setPriceEndOfLife(time() + 60*60*24*30) + ->save(); + $this->cartItems[] = $cartItem; + } + + $this->container->get('request')->getSession()->setCart($cart->getId()); + + return $cart; + } + + public function testSetDeliveryAddress() + { + //$validAddressId = AddressQuery::create()->findOneByCustomerId($this->customer->getId()); + + $this->orderEvent->setDeliveryAddress(321); + + $this->orderAction->setDeliveryAddress($this->orderEvent); + + $this->assertEquals( + 321, + $this->orderEvent->getOrder()->chosenDeliveryAddress + ); + } + + public function testSetinvoiceAddress() + { + $this->orderEvent->setInvoiceAddress(654); + + $this->orderAction->setInvoiceAddress($this->orderEvent); + + $this->assertEquals( + 654, + $this->orderEvent->getOrder()->chosenInvoiceAddress + ); + } + + public function testSetDeliveryModule() + { + $this->orderEvent->setDeliveryModule(123); + + $this->orderAction->setDeliveryModule($this->orderEvent); + + $this->assertEquals( + 123, + $this->orderEvent->getOrder()->getDeliveryModuleId() + ); + } + + public function testSetPaymentModule() + { + $this->orderEvent->setPaymentModule(456); + + $this->orderAction->setPaymentModule($this->orderEvent); + + $this->assertEquals( + 456, + $this->orderEvent->getOrder()->getPaymentModuleId() + ); + } + + public function testCreate() + { + $validDeliveryAddress = AddressQuery::create()->findOneByCustomerId($this->customer->getId()); + $validInvoiceAddress = AddressQuery::create()->filterById($validDeliveryAddress->getId(), Criteria::NOT_EQUAL)->findOneByCustomerId($this->customer->getId()); + + $deliveryModule = ModuleQuery::create() + ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) + ->filterByActivate(1) + ->findOne(); + + if(null === $deliveryModule) { + return; + } + + $paymentModule = ModuleQuery::create() + ->filterByType(BaseModule::PAYMENT_MODULE_TYPE) + ->filterByActivate(1) + ->findOne(); + + if(null === $paymentModule) { + return; + } + + $this->orderEvent->getOrder()->chosenDeliveryAddress = $validDeliveryAddress->getId(); + $this->orderEvent->getOrder()->chosenInvoiceAddress = $validInvoiceAddress->getId(); + $this->orderEvent->getOrder()->setDeliveryModuleId($deliveryModule->getId()); + $this->orderEvent->getOrder()->setPostage(20); + $this->orderEvent->getOrder()->setPaymentModuleId($paymentModule->getId()); + + /* memorize current stocks */ + $itemsStock = array(); + foreach($this->cartItems as $index => $cartItem) { + $itemsStock[$index] = $cartItem->getProductSaleElements()->getQuantity(); + } + + $this->orderAction->create($this->orderEvent); + + $placedOrder = $this->orderEvent->getPlacedOrder(); + + $this->assertNotNull($placedOrder); + $this->assertNotNull($placedOrder->getId()); + + /* check customer */ + $this->assertEquals($this->customer->getId(), $placedOrder->getCustomerId(), 'customer i does not match'); + + /* check delivery address */ + $deliveryOrderAddress = $placedOrder->getOrderAddressRelatedByDeliveryOrderAddressId(); + $this->assertEquals($validDeliveryAddress->getCustomerTitle()->getId(), $deliveryOrderAddress->getCustomerTitleId(), 'delivery address title does not match'); + $this->assertEquals($validDeliveryAddress->getCompany(), $deliveryOrderAddress->getCompany(), 'delivery address company does not match'); + $this->assertEquals($validDeliveryAddress->getFirstname(), $deliveryOrderAddress->getFirstname(), 'delivery address fistname does not match'); + $this->assertEquals($validDeliveryAddress->getLastname(), $deliveryOrderAddress->getLastname(), 'delivery address lastname does not match'); + $this->assertEquals($validDeliveryAddress->getAddress1(), $deliveryOrderAddress->getAddress1(), 'delivery address address1 does not match'); + $this->assertEquals($validDeliveryAddress->getAddress2(), $deliveryOrderAddress->getAddress2(), 'delivery address address2 does not match'); + $this->assertEquals($validDeliveryAddress->getAddress3(), $deliveryOrderAddress->getAddress3(), 'delivery address address3 does not match'); + $this->assertEquals($validDeliveryAddress->getZipcode(), $deliveryOrderAddress->getZipcode(), 'delivery address zipcode does not match'); + $this->assertEquals($validDeliveryAddress->getCity(), $deliveryOrderAddress->getCity(), 'delivery address city does not match'); + $this->assertEquals($validDeliveryAddress->getPhone(), $deliveryOrderAddress->getPhone(), 'delivery address phone does not match'); + $this->assertEquals($validDeliveryAddress->getCountryId(), $deliveryOrderAddress->getCountryId(), 'delivery address country does not match'); + + /* check invoice address */ + $invoiceOrderAddress = $placedOrder->getOrderAddressRelatedByInvoiceOrderAddressId(); + $this->assertEquals($validInvoiceAddress->getCustomerTitle()->getId(), $invoiceOrderAddress->getCustomerTitleId(), 'invoice address title does not match'); + $this->assertEquals($validInvoiceAddress->getCompany(), $invoiceOrderAddress->getCompany(), 'invoice address company does not match'); + $this->assertEquals($validInvoiceAddress->getFirstname(), $invoiceOrderAddress->getFirstname(), 'invoice address fistname does not match'); + $this->assertEquals($validInvoiceAddress->getLastname(), $invoiceOrderAddress->getLastname(), 'invoice address lastname does not match'); + $this->assertEquals($validInvoiceAddress->getAddress1(), $invoiceOrderAddress->getAddress1(), 'invoice address address1 does not match'); + $this->assertEquals($validInvoiceAddress->getAddress2(), $invoiceOrderAddress->getAddress2(), 'invoice address address2 does not match'); + $this->assertEquals($validInvoiceAddress->getAddress3(), $invoiceOrderAddress->getAddress3(), 'invoice address address3 does not match'); + $this->assertEquals($validInvoiceAddress->getZipcode(), $invoiceOrderAddress->getZipcode(), 'invoice address zipcode does not match'); + $this->assertEquals($validInvoiceAddress->getCity(), $invoiceOrderAddress->getCity(), 'invoice address city does not match'); + $this->assertEquals($validInvoiceAddress->getPhone(), $invoiceOrderAddress->getPhone(), 'invoice address phone does not match'); + $this->assertEquals($validInvoiceAddress->getCountryId(), $invoiceOrderAddress->getCountryId(), 'invoice address country does not match'); + + /* check currency */ + $this->assertEquals($this->cart->getCurrencyId(), $placedOrder->getCurrencyId(), 'currency id does not match'); + $this->assertEquals($this->cart->getCurrency()->getRate(), $placedOrder->getCurrencyRate(), 'currency rate does not match'); + + /* check delivery module */ + $this->assertEquals(20, $placedOrder->getPostage(), 'postage does not match'); + $this->assertEquals($deliveryModule->getId(), $placedOrder->getDeliveryModuleId(), 'delivery module does not match'); + + /* check payment module */ + $this->assertEquals($paymentModule->getId(), $placedOrder->getPaymentModuleId(), 'payment module does not match'); + + /* check status */ + $this->assertEquals(OrderStatus::CODE_NOT_PAID, $placedOrder->getOrderStatus()->getCode(), 'status does not match'); + + /* check lang */ + $this->assertEquals($this->container->get('request')->getSession()->getLang()->getId(), $placedOrder->getLangId(), 'lang does not match'); + + /* check ordered product */ + foreach($this->cartItems as $index => $cartItem) { + $orderProduct = OrderProductQuery::create() + ->filterByOrderId($placedOrder->getId()) + ->filterByProductRef($cartItem->getProduct()->getRef()) + ->filterByProductSaleElementsRef($cartItem->getProductSaleElements()->getRef()) + ->filterByQuantity($cartItem->getQuantity()) + ->filterByPrice($cartItem->getPrice(), Criteria::LIKE) + ->filterByPromoPrice($cartItem->getPromoPrice(), Criteria::LIKE) + ->filterByWasNew($cartItem->getProductSaleElements()->getNewness()) + ->filterByWasInPromo($cartItem->getPromo()) + ->filterByWeight($cartItem->getProductSaleElements()->getWeight()) + ->findOne(); + + $this->assertNotNull($orderProduct); + + /* check attribute combinations */ + $this->assertEquals( + $cartItem->getProductSaleElements()->getAttributeCombinations()->count(), + $orderProduct->getOrderProductAttributeCombinations()->count() + ); + + /* check stock decrease */ + $this->assertEquals( + $itemsStock[$index] - $orderProduct->getQuantity(), + $cartItem->getProductSaleElements()->getQuantity() + ); + + /* check tax */ + $orderProductTaxList = $orderProduct->getOrderProductTaxes(); + foreach($cartItem->getProduct()->getTaxRule()->getTaxDetail($validDeliveryAddress->getCountry(), $cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice()) as $index => $tax) { + $orderProductTax = $orderProductTaxList[$index]; + $this->assertEquals($tax->getAmount(), $orderProductTax->getAmount()); + } + } + + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-1.txt b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-1.txt new file mode 100644 index 000000000..82537f32d --- /dev/null +++ b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-1.txt @@ -0,0 +1 @@ +This is a text document. \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-2.txt b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-2.txt new file mode 100644 index 000000000..82537f32d --- /dev/null +++ b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-2.txt @@ -0,0 +1 @@ +This is a text document. \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php b/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php new file mode 100755 index 000000000..1d6d08e92 --- /dev/null +++ b/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php @@ -0,0 +1,106 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Thelia\Command\ModuleActivateCommand; +use Thelia\Core\Application; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; + +/** + * Class ModuleActivateCommandTest + * + * @package Thelia\Tests\Command + * @author Etienne Roudeix + */ +class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testModuleActivateCommand() + { + $module = ModuleQuery::create()->findOne(); + + if(null !== $module) { + $application = new Application($this->getKernel()); + + $module->setActivate(BaseModule::IS_NOT_ACTIVATED); + $module->save(); + + $moduleActivate = new ModuleActivateCommand(); + $moduleActivate->setContainer($this->getContainer()); + + $application->add($moduleActivate); + + $command = $application->find("module:activate"); + $commandTester = new CommandTester($command); + $commandTester->execute(array( + "command" => $command->getName(), + "module" => $module->getCode(), + )); + + $this->assertEquals(BaseModule::IS_ACTIVATED, ModuleQuery::create()->findPk($module->getId())->getActivate()); + } + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage module Letshopethismoduledoesnotexists not found + */ + public function testModuleActivateCommandUnknownModule() + { + $testedModule = ModuleQuery::create()->findOneByCode('Letshopethismoduledoesnotexists'); + + if(null == $testedModule) { + $application = new Application($this->getKernel()); + + + $moduleActivate = new ModuleActivateCommand(); + $moduleActivate->setContainer($this->getContainer()); + + $application->add($moduleActivate); + + $command = $application->find("module:activate"); + $commandTester = new CommandTester($command); + $commandTester->execute(array( + "command" => $command->getName(), + "module" => "letshopethismoduledoesnotexists", + )); + + $out = true; + } + } + + public function getKernel() + { + $kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface"); + + return $kernel; + } + + public function getContainer() + { + $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); + + return $container; + } +} diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php index 01e9dde69..68818a092 100644 --- a/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php +++ b/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php @@ -65,6 +65,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue($ConstraintValidator)); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -79,7 +82,7 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $rules = new CouponRuleCollection(); $rules->add($rule1); - $isValid = $ConstraintValidator->test($rules); + $isValid = $ConstraintValidator->isMatching($rules); $expected = true; $actual =$isValid; @@ -99,6 +102,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue($ConstraintValidator)); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -113,7 +119,7 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $rules = new CouponRuleCollection(); $rules->add($rule1); - $isValid = $ConstraintValidator->test($rules); + $isValid = $ConstraintValidator->isMatching($rules); $expected = false; $actual =$isValid; @@ -136,6 +142,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(5)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue($ConstraintValidator)); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -160,7 +169,7 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $rules->add($rule1); $rules->add($rule2); - $isValid = $ConstraintValidator->test($rules); + $isValid = $ConstraintValidator->isMatching($rules); $expected = true; $actual =$isValid; @@ -183,6 +192,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(5)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue($ConstraintValidator)); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -207,7 +219,7 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $rules->add($rule1); $rules->add($rule2); - $isValid = $ConstraintValidator->test($rules); + $isValid = $ConstraintValidator->isMatching($rules); $expected = false; $actual =$isValid; diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php index 4c6da4ad2..c3f7249df 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon; +use Thelia\Constraint\ConstraintValidator; use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; @@ -169,6 +170,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -205,6 +209,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -241,6 +248,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -277,6 +287,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -313,6 +326,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -349,6 +365,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -385,6 +404,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -421,6 +443,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -457,6 +482,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -493,6 +521,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -529,6 +560,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -565,6 +599,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -601,6 +638,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -637,6 +677,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getCheckoutCurrency') ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php index 76a744848..4ecbcb8ac 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon; +use Thelia\Constraint\ConstraintValidator; use Thelia\Constraint\Rule\AvailableForXArticlesManager; use Thelia\Constraint\Rule\Operators; use Thelia\Constraint\Rule\SerializableRule; @@ -192,6 +193,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -224,6 +228,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -256,6 +263,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -288,6 +298,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -320,6 +333,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -352,6 +368,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -384,6 +403,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -416,6 +438,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -448,6 +473,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -480,6 +508,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -512,6 +543,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -544,6 +578,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -570,6 +607,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( @@ -602,6 +642,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); $rule1 = new AvailableForXArticlesManager($stubAdapter); $operators = array( diff --git a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php index 2b31d265a..eb271d4c1 100755 --- a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php +++ b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php @@ -132,7 +132,7 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('\Thelia\Core\Template\Element\LoopResult', $methodReturn); } - public function baseTestSearchById($id) + public function baseTestSearchById($id, $other_args = array()) { $this->instance->initializeArgs(array_merge( $this->getMandatoryArguments(), @@ -140,7 +140,8 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase "type" => "foo", "name" => "foo", "id" => $id, - ) + ), + $other_args )); $dummy = null; diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php new file mode 100644 index 000000000..2b7019879 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Model\DocumentQuery; +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Document; +use Thelia\Model\ProductDocumentQuery; +use Thelia\Model\CategoryDocumentQuery; +use Thelia\Model\ContentDocumentQuery; +use Thelia\Model\FolderDocumentQuery; + +/** + * + * @author Etienne Roudeix + * + */ +class DocumentTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Document'; + } + + public function getTestedInstance() + { + return new Document($this->container); + } + + public function getMandatoryArguments() + { + return array('source' => 'product', 'id' => 1); + } + + public function testSearchByProductId() + { + $document = ProductDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'product')); + } + + public function testSearchByFolderId() + { + $document = FolderDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'folder')); + } + + public function testSearchByContentId() + { + $document = ContentDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'content')); + } + + public function testSearchByCategoryId() + { + $document = CategoryDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'category')); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php new file mode 100644 index 000000000..ba4bfadc5 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Model\ImageQuery; +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Image; +use Thelia\Model\ProductImageQuery; +use Thelia\Model\CategoryImageQuery; +use Thelia\Model\ContentImageQuery; +use Thelia\Model\FolderImageQuery; + +/** + * + * @author Etienne Roudeix + * + */ +class ImageTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Image'; + } + + public function getTestedInstance() + { + return new Image($this->container); + } + + public function getMandatoryArguments() + { + return array('source' => 'product', 'id' => 1); + } + + public function testSearchByProductId() + { + $image = ProductImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'product')); + } + + public function testSearchByFolderId() + { + $image = FolderImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'folder')); + } + + public function testSearchByContentId() + { + $image = ContentImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'content')); + } + + public function testSearchByCategoryId() + { + $image = CategoryImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'category')); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php index 1b307c5b5..07e179cbd 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php @@ -27,6 +27,7 @@ use Thelia\Model\ProductQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Product; +use Propel\Runtime\ActiveQuery\Criteria; /** * @@ -52,7 +53,7 @@ class ProductTest extends BaseLoopTestor public function testSearchById() { - $product = ProductQuery::create()->findOne(); + $product = ProductQuery::create()->orderById(Criteria::ASC)->findOne(); $this->baseTestSearchById($product->getId()); } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php new file mode 100644 index 000000000..fa24d72ee --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\TaxRule; +use Thelia\Model\TaxRuleQuery; + +/** + * + * @author Etienne Roudeix + * + */ +class TaxRuleTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\TaxRule'; + } + + public function getTestedInstance() + { + return new TaxRule($this->container); + } + + public function getMandatoryArguments() + { + return array(); + } + + public function testSearchById() + { + $tr = TaxRuleQuery::create()->findOne(); + + $this->baseTestSearchById($tr->getId(), array('force_return' => true)); + } + +} diff --git a/core/lib/Thelia/Tests/Form/OrderDeliveryTest.php b/core/lib/Thelia/Tests/Form/OrderDeliveryTest.php new file mode 100755 index 000000000..980c17d88 --- /dev/null +++ b/core/lib/Thelia/Tests/Form/OrderDeliveryTest.php @@ -0,0 +1,32 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Form; + +class OrderDeliveryTest extends \PHPUnit_Framework_TestCase +{ + + public function testOrderDelivery() + { + + } +} diff --git a/core/lib/Thelia/Tests/Module/BaseModuleTestor.php b/core/lib/Thelia/Tests/Module/BaseModuleTestor.php new file mode 100644 index 000000000..ce70cd4ad --- /dev/null +++ b/core/lib/Thelia/Tests/Module/BaseModuleTestor.php @@ -0,0 +1,53 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Module; + + +/** + * + * @author Etienne Roudeix + * + */ +abstract class BaseModuleTestor extends \PHPUnit_Framework_TestCase +{ + protected $instance; + + abstract public function getTestedClassName(); + abstract public function getTestedInstance(); + + /*protected function getMethod($name) + { + $class = new \ReflectionClass($this->getTestedClassName()); + $method = $class->getMethod($name); + $method->setAccessible(true); + + return $method; + }*/ + + public function setUp() + { + $this->instance = $this->getTestedInstance(); + } +} + diff --git a/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php b/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php new file mode 100644 index 000000000..449a9162d --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php @@ -0,0 +1,108 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; + + +/** + * Class BaseRewritingObject + * @package Thelia\Tests\Rewriting + * @author Manuel Raynaud + */ +abstract class BaseRewritingObject extends \PHPUnit_Framework_TestCase +{ + + /** + * @return mixed an instance of Product, Folder, Content or Category Model + */ + abstract function getObject(); + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + */ + public function testSimpleFrenchRewrittenUrl() + { + $object = $this->getObject(); + $object->setVisible(1) + ->setPosition(1) + ->setLocale('fr_FR') + ->setTitle('Mon super titre en français') + ->save(); + + $this->assertRegExp('/^mon-super-titre-en-français(-[0-9]+)?\.html$/', $object->getRewrittenUrl('fr_FR')); + + $rewrittenUrl = $object->generateRewrittenUrl('fr_FR'); + $this->assertNotNull($rewrittenUrl, "rewritten url can not be null"); + $this->assertRegExp('/^mon-super-titre-en-français(-[0-9]+)?\.html$/', $rewrittenUrl); + //mon-super-titre-en-français-2.html + + $object->delete(); + } + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + */ + public function testSimpleEnglishRewrittenUrl() + { + $object = $this->getObject(); + $object->setVisible(1) + ->setPosition(1) + ->setLocale('en_US') + ->setTitle('My english super Title') + ->save(); + + $this->assertRegExp('/^my-english-super-title(-[0-9]+)?\.html$/', $object->getRewrittenUrl('en_US')); + + $rewrittenUrl = $object->generateRewrittenUrl('en_US'); + $this->assertNotNull($rewrittenUrl, "rewritten url can not be null"); + $this->assertRegExp('/^my-english-super-title(-[0-9]+)?\.html$/', $rewrittenUrl); + + $object->delete(); + } + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + * @expectedException \RuntimeException + * @expectedExceptionMessage Impossible to create an url if title is null + */ + public function testRewrittenWithoutTitle() + { + $object = $this->getObject(); + $object->setVisible(1) + ->setPosition(1) + ->setLocale('en_US') + ->setDescription('My english super Description') + ->save(); + } + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + * @expectedException \RuntimeException + */ + public function testOnNotSavedObject() + { + $object = $this->getObject(); + + $object->generateRewrittenUrl('fr_FR'); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php b/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php new file mode 100644 index 000000000..247fdc8a9 --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php @@ -0,0 +1,43 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; +use Thelia\Model\Category; + + +/** + * Class CategoryRewritingTest + * @package Thelia\Tests\Rewriting + * @author Manuel Raynaud + */ +class CategoryRewritingTest extends BaseRewritingObject +{ + + /** + * @return \Thelia\Model\Category + */ + function getObject() + { + return new Category(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php b/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php new file mode 100644 index 000000000..e06ff62b2 --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php @@ -0,0 +1,43 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; +use Thelia\Model\Content; + + +/** + * Class ContentRewritingTest + * @package Thelia\Tests\Rewriting + * @author Manuel Raynaud + */ +class ContentRewritingTest extends BaseRewritingObject +{ + + /** + * @return \Thelia\Model\Content + */ + function getObject() + { + return new Content(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php b/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php new file mode 100644 index 000000000..db0dbc897 --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php @@ -0,0 +1,43 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; +use Thelia\Model\Folder; + + +/** + * Class FolderRewritingTest + * @package Thelia\Tests\Rewriting + * @author Manuel Raynaud + */ +class FolderRewritingTest extends BaseRewritingObject +{ + + /** + * @return mixed an instance of Product, Folder, Content or Category Model + */ + function getObject() + { + return new Folder(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php new file mode 100644 index 000000000..2bff1bf5c --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; +use Thelia\Model\Product; +use Thelia\Model\ProductQuery; + + +/** + * Class ProductRewriteTest + * @package Thelia\Tests\Rewriting + * @author Manuel Raynaud + */ +class ProductRewriteTest extends BaseRewritingObject +{ + + /** + * @return mixed an instance of Product, Folder, Content or Category Model + */ + function getObject() + { + return new Product(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php index e0443c5ba..f8c6ec6c0 100755 --- a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php +++ b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php @@ -78,7 +78,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase public function testLoad() { - $productQuery = ProductQuery::create()->findOneById(1); + $productQuery = ProductQuery::create()->findOne(); $countryQuery = CountryQuery::create()->findOneById(64); $calculator = new Calculator(); @@ -86,7 +86,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorCollection')); $taxRuleQuery->expects($this->once()) ->method('getTaxCalculatorCollection') - ->with($productQuery, $countryQuery) + ->with($productQuery->getTaxRule(), $countryQuery) ->will($this->returnValue('foo')); $rewritingUrlQuery = $this->getProperty('taxRuleQuery'); diff --git a/core/lib/Thelia/Tools/I18n.php b/core/lib/Thelia/Tools/I18n.php index 1f3ff57dd..aeb79ca84 100644 --- a/core/lib/Thelia/Tools/I18n.php +++ b/core/lib/Thelia/Tools/I18n.php @@ -23,6 +23,8 @@ namespace Thelia\Tools; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Thelia\Model\Lang; /** @@ -54,4 +56,39 @@ class I18n return \DateTime::createFromFormat($currentDateFormat, $date); } + + public static function forceI18nRetrieving($askedLocale, $modelName, $id, $needed = array('Title')) + { + $i18nQueryClass = sprintf("\\Thelia\\Model\\%sI18nQuery", $modelName); + $i18nClass = sprintf("\\Thelia\\Model\\%sI18n", $modelName); + + /* get customer language translation */ + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + $askedLocale + )->findOne(); + /* or default translation */ + if(null === $i18n) { + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + Lang::getDefaultLanguage()->getLocale() + )->findOne(); + } + if(null === $i18n) { // @todo something else ? + $i18n = new $i18nClass();; + $i18n->setId($id); + foreach($needed as $need) { + $method = sprintf('set%s', $need); + if(method_exists($i18n, $method)) { + $i18n->$method('DEFAULT ' . strtoupper($need)); + } else { + // @todo throw sg ? + } + } + } + + return $i18n; + } } diff --git a/core/lib/Thelia/Tools/Image.php b/core/lib/Thelia/Tools/Image.php new file mode 100755 index 000000000..5fa4d3c6c --- /dev/null +++ b/core/lib/Thelia/Tools/Image.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tools; + +class Image +{ + static public function isImage($filePath, $allowedImageTypes = null) + { + $imageFile = getimagesize($filePath); + $imageType = $imageFile[2]; + + if(!is_array($allowedImageTypes) && $imageType != IMAGETYPE_UNKNOWN) { + return true; + } + + if(in_array($imageType , $allowedImageTypes)) + { + return true; + } + + return false; + } +} diff --git a/core/lib/Thelia/Tools/Redirect.php b/core/lib/Thelia/Tools/Redirect.php index 6908892f7..ed7932080 100755 --- a/core/lib/Thelia/Tools/Redirect.php +++ b/core/lib/Thelia/Tools/Redirect.php @@ -27,12 +27,12 @@ use Symfony\Component\HttpFoundation\RedirectResponse; class Redirect { - public static function exec($url, $status = 302) { $response = new RedirectResponse($url, $status); $response->send(); + exit; } } diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 32c1aadb5..363860064 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -43,14 +43,15 @@ class URL protected static $instance = null; - public function __construct(ContainerInterface $container) + public function __construct(ContainerInterface $container = null) { // Allow singleton style calls once intanciated. // For this to work, the URL service has to be instanciated very early. This is done manually // in TheliaHttpKernel, by calling $this->container->get('thelia.url.manager'); self::$instance = $this; - $this->requestContext = $container->get('router.admin')->getContext(); + if ($container !== null) + $this->requestContext = $container->get('router.admin')->getContext(); $this->retriever = new RewritingRetriever(); $this->resolver = new RewritingResolver(); @@ -183,6 +184,7 @@ class URL return $this->absoluteUrl($path, $parameters); } + /** * Retrieve a rewritten URL from a view, a view id and a locale * @@ -261,4 +263,50 @@ class URL return $this->resolver; } + + protected function sanitize($string, $force_lowercase = true, $alphabetic_only = false) + { + static $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", + "}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—", + "—", "–", ",", "<", ".", ">", "/", "?"); + + $clean = trim(str_replace($strip, "", strip_tags($string))); + + $clean = preg_replace('/\s+/', "-", $clean); + + $clean = ($alphabetic_only) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ; + + return ($force_lowercase) ? + (function_exists('mb_strtolower')) ? + mb_strtolower($clean, 'UTF-8') : + strtolower($clean) : + $clean; + } + + /** + * Genenerate the file part of a rewriten URL from a given baseString, using a view, a view id and a locale + * + * @param $view + * @param $viewId + * @param $viewLocale + * @param $baseString the string to be converted in a valid URL + * + * @return A valid file part URL. + */ + public function generateRewritenUrl($view, $viewId, $viewLocale, $baseString) + { + // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe + + // Replace all weird characters with dashes + $string = preg_replace('/[^\w\-~_\.]+/u', '-', $baseString); + + // Only allow one dash separator at a time (and make string lowercase) + $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8'); + + $urlFilePart = $cleanString . ".html"; + + // TODO : + // check if URL url already exists, and add a numeric suffix, or the like + // insert the URL in the rewriting table + } } diff --git a/install/faker.php b/install/faker.php index fdcf6212c..60232e2ea 100755 --- a/install/faker.php +++ b/install/faker.php @@ -1,17 +1,10 @@ beginTransaction(); +// Intialize URL management +$url = new Thelia\Tools\URL(); + $currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne(); try { $stmt = $con->prepare("SET foreign_key_checks = 0"); $stmt->execute(); + echo "Clearing tables\n"; + $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() ->find(); $productAssociatedContent->delete(); @@ -39,14 +37,6 @@ try { ->find(); $categoryAssociatedContent->delete(); - $attributeCategory = Thelia\Model\AttributeCategoryQuery::create() - ->find(); - $attributeCategory->delete(); - - $featureCategory = Thelia\Model\FeatureCategoryQuery::create() - ->find(); - $featureCategory->delete(); - $featureProduct = Thelia\Model\FeatureProductQuery::create() ->find(); $featureProduct->delete(); @@ -135,9 +125,24 @@ try { ->find(); $productPrice->delete(); + \Thelia\Model\ProductImageQuery::create()->find()->delete(); + \Thelia\Model\CategoryImageQuery::create()->find()->delete(); + \Thelia\Model\FolderImageQuery::create()->find()->delete(); + \Thelia\Model\ContentImageQuery::create()->find()->delete(); + + \Thelia\Model\ProductDocumentQuery::create()->find()->delete(); + \Thelia\Model\CategoryDocumentQuery::create()->find()->delete(); + \Thelia\Model\FolderDocumentQuery::create()->find()->delete(); + \Thelia\Model\ContentDocumentQuery::create()->find()->delete(); + + \Thelia\Model\CouponQuery::create()->find()->delete(); + $stmt = $con->prepare("SET foreign_key_checks = 1"); + $stmt->execute(); + echo "Creating customer\n"; + //customer $customer = new Thelia\Model\Customer(); $customer->createOrUpdate( @@ -155,6 +160,24 @@ try { "test@thelia.net", "azerty" ); + for ($j = 0; $j <= 3; $j++) { + $address = new Thelia\Model\Address(); + $address->setLabel($faker->text(20)) + ->setTitleId(rand(1,3)) + ->setFirstname($faker->firstname) + ->setLastname($faker->lastname) + ->setAddress1($faker->streetAddress) + ->setAddress2($faker->streetAddress) + ->setAddress3($faker->streetAddress) + ->setCellphone($faker->phoneNumber) + ->setPhone($faker->phoneNumber) + ->setZipcode($faker->postcode) + ->setCity($faker->city) + ->setCountryId(64) + ->setCustomer($customer) + ->save() + ; + } for($i = 0; $i < 50; $i++) { $customer = new Thelia\Model\Customer(); @@ -195,11 +218,13 @@ try { } } + echo "Creating features\n"; + //features and features_av $featureList = array(); for($i=0; $i<4; $i++) { $feature = new Thelia\Model\Feature(); - $feature->setVisible(rand(1, 10)>7 ? 0 : 1); + $feature->setVisible(1); $feature->setPosition($i); setI18n($faker, $feature); @@ -218,6 +243,8 @@ try { } } + echo "Creating attributes\n"; + //attributes and attributes_av $attributeList = array(); for($i=0; $i<4; $i++) { @@ -240,52 +267,99 @@ try { } } + echo "Creating templates\n"; + + $template = new Thelia\Model\Template(); + setI18n($faker, $template, array("Name" => 20)); + $template->save(); + + foreach($attributeList as $attributeId => $attributeAvId) { + $at = new Thelia\Model\AttributeTemplate(); + + $at + ->setTemplate($template) + ->setAttributeId($attributeId) + ->save(); + } + + foreach($featureList as $featureId => $featureAvId) { + $ft = new Thelia\Model\FeatureTemplate(); + + $ft + ->setTemplate($template) + ->setFeatureId($featureId) + ->save(); + } + + echo "Creating folders and content\n"; + //folders and contents $contentIdList = array(); for($i=0; $i<4; $i++) { $folder = new Thelia\Model\Folder(); $folder->setParent(0); - $folder->setVisible(rand(1, 10)>7 ? 0 : 1); - $folder->setPosition($i); + $folder->setVisible(1); + $folder->setPosition($i+1); setI18n($faker, $folder); $folder->save(); - $image = new FolderImage(); + $image = new \Thelia\Model\FolderImage(); $image->setFolderId($folder->getId()); generate_image($image, 1, 'folder', $folder->getId()); - for($j=1; $jsetFolderId($folder->getId()); + generate_document($document, 1, 'folder', $folder->getId()); + + for($j=0; $j<3; $j++) { $subfolder = new Thelia\Model\Folder(); $subfolder->setParent($folder->getId()); - $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); - $subfolder->setPosition($j); + $subfolder->setVisible(1); + $subfolder->setPosition($j+1); setI18n($faker, $subfolder); $subfolder->save(); - $image = new FolderImage(); + $image = new \Thelia\Model\FolderImage(); $image->setFolderId($subfolder->getId()); generate_image($image, 1, 'folder', $subfolder->getId()); - for($k=0; $ksetFolderId($folder->getId()); + generate_document($document, 1, 'folder', $subfolder->getId()); + + for($k=0; $k<4; $k++) { $content = new Thelia\Model\Content(); $content->addFolder($subfolder); - $content->setVisible(rand(1, 10)>7 ? 0 : 1); - $content->setPosition($k); + + $contentFolders = $content->getContentFolders(); + $collection = new \Propel\Runtime\Collection\Collection(); + $collection->prepend($contentFolders[0]->setDefaultFolder(1)); + $content->setContentFolders($collection); + + $content->setVisible(1); + $content->setPosition($k+1); setI18n($faker, $content); $content->save(); $contentId = $content->getId(); $contentIdList[] = $contentId; - $image = new ContentImage(); - $image->setContentId($content->getId()); + $image = new \Thelia\Model\ContentImage(); + $image->setContentId($contentId); generate_image($image, 1, 'content', $contentId); + + $document = new \Thelia\Model\ContentDocument(); + $document->setContentId($contentId); + generate_document($document, 1, 'content', $contentId); + } } } + echo "Creating categories and products\n"; + //categories and products $productIdList = array(); $categoryIdList = array(); @@ -296,28 +370,12 @@ try { $subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList, $contentIdList); for($k=0; $k $attributeAvId) { - $attributeCategory = new Thelia\Model\AttributeCategory(); - $attributeCategory->setCategoryId($categoryId) - ->setAttributeId($attributeId) - ->save(); - } - foreach($featureList as $featureId => $featureAvId) { - $featureCategory = new Thelia\Model\FeatureCategory(); - $featureCategory->setCategoryId($categoryId) - ->setFeatureId($featureId) - ->save(); + createProduct($faker, $category, $k, $template, $productIdList); } } @@ -344,6 +402,7 @@ try { $productAssociatedContent = new Thelia\Model\ProductAssociatedContent(); do { $pick = array_rand($contentIdList, 1); + \Thelia\Log\Tlog::getInstance()->debug("pick : $pick"); } while(in_array($pick, $alreadyPicked)); $alreadyPicked[] = $pick; @@ -408,32 +467,48 @@ try { } } + echo "Generating coupons fixtures\n"; + generateCouponFixtures($thelia); $con->commit(); + + echo "Successfully terminated.\n"; + } catch (Exception $e) { echo "error : ".$e->getMessage()."\n"; $con->rollBack(); } -function createProduct($faker, $category, $position, &$productIdList) +function createProduct($faker, Thelia\Model\Category $category, $position, $template, &$productIdList) { $product = new Thelia\Model\Product(); $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8)); $product->addCategory($category); - $product->setVisible(rand(1, 10)>7 ? 0 : 1); + $product->setVisible(1); + $productCategories = $product->getProductCategories(); + $collection = new \Propel\Runtime\Collection\Collection(); + $collection->prepend($productCategories[0]->setDefaultCategory(1)); + $product->setProductCategories($collection); + $product->setVisible(1); $product->setPosition($position); $product->setTaxRuleId(1); + $product->setTemplate($template); + setI18n($faker, $product); $product->save(); $productId = $product->getId(); $productIdList[] = $productId; - $image = new ProductImage(); + $image = new \Thelia\Model\ProductImage(); $image->setProductId($productId); generate_image($image, 1, 'product', $productId); + $document = new \Thelia\Model\ProductDocument(); + $document->setProductId($productId); + generate_document($document, 1, 'product', $productId); + return $product; } @@ -441,7 +516,7 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId { $category = new Thelia\Model\Category(); $category->setParent($parent); - $category->setVisible(rand(1, 10)>7 ? 0 : 1); + $category->setVisible(1); $category->setPosition($position); setI18n($faker, $category); @@ -465,10 +540,14 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId ->save(); } - $image = new CategoryImage(); + $image = new \Thelia\Model\CategoryImage(); $image->setCategoryId($categoryId); generate_image($image, 1, 'category', $categoryId); + $document = new \Thelia\Model\CategoryDocument(); + $document->setCategoryId($categoryId); + generate_document($document, 1, 'category', $categoryId); + return $category; } @@ -481,37 +560,36 @@ function generate_image($image, $position, $typeobj, $id) { ->setDescription($faker->text(250)) ->setChapo($faker->text(40)) ->setPostscriptum($faker->text(40)) - ->setPosition($position) ->setFile(sprintf("sample-image-%s.png", $id)) ->save() ; // Generate images $imagine = new Imagine\Gd\Imagine(); - $image = $imagine->create(new Imagine\Image\Box(320,240), new Color('#E9730F')); + $image = $imagine->create(new Imagine\Image\Box(320,240), new Imagine\Image\Color('#E9730F')); - $white = new Color('#FFF'); + $white = new Imagine\Image\Color('#FFF'); $font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 14, $white); $tbox = $font->box("THELIA"); - $image->draw()->text("THELIA", $font, new Point((320 - $tbox->getWidth()) / 2, 30)); + $image->draw()->text("THELIA", $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 30)); $str = sprintf("%s sample image", ucfirst($typeobj)); $tbox = $font->box($str); - $image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 80)); + $image->draw()->text($str, $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 80)); $font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 18, $white); $str = sprintf("%s ID %d", strtoupper($typeobj), $id); $tbox = $font->box($str); - $image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 180)); + $image->draw()->text($str, $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 180)); $image->draw() - ->line(new Point(0, 0), new Point(319, 0), $white) - ->line(new Point(319, 0), new Point(319, 239), $white) - ->line(new Point(319, 239), new Point(0,239), $white) - ->line(new Point(0, 239), new Point(0, 0), $white) + ->line(new Imagine\Image\Point(0, 0), new Imagine\Image\Point(319, 0), $white) + ->line(new Imagine\Image\Point(319, 0), new Imagine\Image\Point(319, 239), $white) + ->line(new Imagine\Image\Point(319, 239), new Imagine\Image\Point(0,239), $white) + ->line(new Imagine\Image\Point(0, 239), new Imagine\Image\Point(0, 0), $white) ; $image_file = sprintf("%s/../local/media/images/%s/sample-image-%s.png", __DIR__, $typeobj, $id); @@ -521,18 +599,38 @@ function generate_image($image, $position, $typeobj, $id) { $image->save($image_file); } -function setI18n($faker, &$object) -{ - $localeList = array('fr_FR', 'en_EN'); +function generate_document($document, $position, $typeobj, $id) { - $title = $faker->text(20); - $description = $faker->text(50); + global $faker; + + $document + ->setTitle($faker->text(20)) + ->setDescription($faker->text(250)) + ->setChapo($faker->text(40)) + ->setPostscriptum($faker->text(40)) + ->setFile(sprintf("sample-document-%s.txt", $id)) + ->save() + ; + + $document_file = sprintf("%s/../local/media/documents/%s/sample-document-%s.txt", __DIR__, $typeobj, $id); + + if (! is_dir(dirname($document_file))) mkdir(dirname($document_file), 0777, true); + + file_put_contents($document_file, $faker->text(256)); +} + +function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' => 50) ) +{ + $localeList = $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT'); foreach($localeList as $locale) { $object->setLocale($locale); - $object->setTitle($locale . ' : ' . $title); - $object->setDescription($locale . ' : ' . $description); + foreach($fields as $name => $length) { + $func = "set".ucfirst(strtolower($name)); + + $object->$func($locale . ' : ' . $faker->text($length)); + } } } /** @@ -599,6 +697,8 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $coupon1->setMaxUsage(40); $coupon1->setIsCumulative(1); $coupon1->setIsRemovingPostage(0); + $coupon1->setIsAvailableOnSpecialOffers(1); + $coupon1->save(); @@ -647,8 +747,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon2->setSerializedRules($serializedRules); - $coupon1->setMaxUsage(-1); + $coupon2->setMaxUsage(-1); $coupon2->setIsCumulative(0); $coupon2->setIsRemovingPostage(1); + $coupon2->setIsAvailableOnSpecialOffers(1); + $coupon2->save(); } diff --git a/install/faker_100categories_1000products_4locales.php b/install/faker_100categories_1000products_4locales.php index ce18aa5c7..eb98d3e10 100755 --- a/install/faker_100categories_1000products_4locales.php +++ b/install/faker_100categories_1000products_4locales.php @@ -156,18 +156,18 @@ try { $con->rollBack(); } -function setI18n($faker, &$object) +function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' => 50) ) { - $localeList = array('fr_FR', 'en_EN', 'es_ES', 'it_IT'); - - $title = $faker->text(20); - $description = $faker->text(50); + $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT'); foreach($localeList as $locale) { $object->setLocale($locale); - $object->setTitle($locale . ' : ' . $title); - $object->setDescription($locale . ' : ' . $description); + foreach($fields as $name => $length) { + $func = "set$name"; + + $object->$func($locale . ' : ' . $faker->text($length)); + } } } diff --git a/install/import.php b/install/import.php new file mode 100644 index 000000000..c5fa3572a --- /dev/null +++ b/install/import.php @@ -0,0 +1,379 @@ +. */ +/* */ +/*************************************************************************************/ + +use Thelia\Constraint\ConstraintFactory; +use Thelia\Constraint\Rule\AvailableForTotalAmountManager; +use Thelia\Constraint\Rule\AvailableForXArticlesManager; +use Thelia\Constraint\Rule\Operators; +use Thelia\Coupon\CouponRuleCollection; + + +require __DIR__ . '/../core/bootstrap.php'; + +$thelia = new Thelia\Core\Thelia("dev", true); +$thelia->boot(); + +$faker = Faker\Factory::create(); +// Intialize URL management +$url = new Thelia\Tools\URL(); +$con = \Propel\Runtime\Propel::getConnection( + Thelia\Model\Map\ProductTableMap::DATABASE_NAME +); +$con->beginTransaction(); + +try { + $stmt = $con->prepare("SET foreign_key_checks = 0"); + $stmt->execute(); + clearTables(); + $stmt = $con->prepare("SET foreign_key_checks = 1"); + $stmt->execute(); + + + $categories = createCategories(); + $color = createColors(); + $brand = createBrand(); + + echo "creating templates\n"; + $template = new \Thelia\Model\Template(); + $template + ->setLocale('fr_FR') + ->setName('template de démo') + ->setLocale('en_US') + ->setName('demo template') + ->save(); + + $at = new Thelia\Model\AttributeTemplate(); + + $at + ->setTemplate($template) + ->setAttribute($color) + ->save(); + + $ft = new Thelia\Model\FeatureTemplate(); + + $ft + ->setTemplate($template) + ->setFeature($brand) + ->save(); + echo "end creating templates\n"; + + createProduct($faker, $categories, $template, $color, $brand); + + + + $con->commit(); +} catch (Exception $e) { + echo "error : ".$e->getMessage()."\n"; + $con->rollBack(); +} + +function createProduct($faker, $categories, $template, $attribute, $feature) +{ + echo "start creating products\n"; + $fileSystem = new \Symfony\Component\Filesystem\Filesystem(); + if (($handle = fopen(THELIA_ROOT . '/install/import/products.csv', "r")) !== FALSE) { + $row=0; + while (($data = fgetcsv($handle, 100000, ";")) !== FALSE) { + $row++; + if($row == 1) continue; + $product = new \Thelia\Model\Product(); + $productCategories = explode(';', $data[13]); + $product + ->setRef($data[0]) + ->setVisible(1) + ->setTaxRuleId(1) + ->setTemplate($template) + ; + foreach($productCategories as $productCategory) { + + $productCategory = trim($productCategory); + if(array_key_exists($productCategory, $categories)) { + $product->addCategory($categories[$productCategory]); + } + } + + + $product + ->setLocale('en_US') + ->setTitle($data[1]) + ->setChapo($data[2]) + ->setDescription($data[4]) + ->setPostscriptum($data[6]) + ->setLocale('fr_Fr') + ->setTitle($data[1]) + ->setChapo($data[3]) + ->setDescription($data[5]) + ->setPostscriptum($data[7]) + ->save(); + + $productCategories = $product->getProductCategories()->getFirst(); + $productCategories->setDefaultCategory(true) + ->save(); + + // Set the position + $product->setPosition($product->getNextPosition())->save(); + + $images = explode(';', $data[10]); + + foreach ($images as $image) { + $image = trim($image); + if(empty($image)) continue; + $productImage = new \Thelia\Model\ProductImage(); + $productImage + ->setProduct($product) + ->setFile($image) + ->save(); + $fileSystem->copy(THELIA_ROOT . 'install/import/images/'.$image, THELIA_ROOT . 'local/media/images/product/'.$image, true); + } + + $pses = explode(";", $data[12]); + + + foreach ($pses as $pse) { + if(empty($pse)) continue; + $stock = new \Thelia\Model\ProductSaleElements(); + $stock->setProduct($product); + $stock->setRef($product->getId() . '_' . uniqid('', true)); + $stock->setQuantity($faker->randomNumber(1,50)); + if(!empty($data[9])) { + $stock->setPromo(1); + } else { + $stock->setPromo(0); + } + + $stock->setNewness($faker->randomNumber(0,1)); + $stock->setWeight($faker->randomFloat(2, 100,10000)); + $stock->save(); + + $productPrice = new \Thelia\Model\ProductPrice(); + $productPrice->setProductSaleElements($stock); + $productPrice->setCurrencyId(1); + $productPrice->setPrice($data[8]); + $productPrice->setPromoPrice($data[9]); + $productPrice->save(); + + $attributeAv = \Thelia\Model\AttributeAvI18nQuery::create() + ->filterByLocale('en_US') + ->filterByTitle($pse) + ->findOne(); + + $attributeCombination = new \Thelia\Model\AttributeCombination(); + $attributeCombination + ->setAttributeId($attribute->getId()) + ->setAttributeAvId($attributeAv->getId()) + ->setProductSaleElements($stock) + ->save(); + } + + $brand = $data[11]; + $featurAv = \Thelia\Model\FeatureAvI18nQuery::create() + ->filterByLocale('en_US') + ->filterByTitle($brand) + ->findOne(); + + $featureProduct = new Thelia\Model\FeatureProduct(); + $featureProduct->setProduct($product) + ->setFeatureId($feature->getId()) + ->setFeatureAvId($featurAv->getId()) + ->save() + ; + + + + } + } + echo "end creating products\n"; +} + +function createBrand() +{ + echo "start creating brands feature\n"; + if (($handle = fopen(THELIA_ROOT . '/install/import/brand.csv', "r")) !== FALSE) { + $row=0; + $feature = new \Thelia\Model\Feature(); + $feature + ->setPosition(1) + ->setLocale('fr_FR') + ->setTitle('Marque') + ->setLocale('en_US') + ->setTitle('Brand'); + while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { + $row++; + $featureAv = new \Thelia\Model\FeatureAv(); + $featureAv + ->setPosition($row) + ->setLocale('fr_FR') + ->setTitle($data[0]) + ->setLocale('en_US') + ->setTitle($data[0]); + $feature->addFeatureAv($featureAv); + + } + $feature->save(); + fclose($handle); + } + echo "brands feature created successfully\n"; + + return $feature; +} + +function createCategories() +{ + echo "start creating categories\n"; + $categories = array(); + if (($handle = fopen(THELIA_ROOT . '/install/import/categories.csv', "r")) !== FALSE) { + $row=0; + while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { + $row++; + if($row==1) continue; + $category = new \Thelia\Model\Category(); + $category + ->setVisible(1) + ->setPosition($row-1) + ->setParent(0) + ->setLocale('fr_FR') + ->setTitle(trim($data[0])) + ->setLocale('en_US') + ->setTitle(trim($data[1])) + ->save(); + $categories[trim($data[1])] = $category; + } + fclose($handle); + } + echo "categories created successfully\n"; + return $categories; +} + +function createColors() +{ + echo "start creating colors attributes\n"; + if (($handle = fopen(THELIA_ROOT . '/install/import/colors.csv', "r")) !== FALSE) { + $row=0; + $attribute = new \Thelia\Model\Attribute(); + $attribute + ->setPosition(1) + ->setLocale('fr_FR') + ->setTitle('Couleur') + ->setLocale('en_US') + ->setTitle('Colors'); + + while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { + $row++; + $attributeAv = new \Thelia\Model\AttributeAv(); + $attributeAv + ->setPosition($row) + ->setLocale('fr_FR') + ->setTitle($data[0]) + ->setLocale('en_US') + ->setTitle($data[1]); + + $attribute->addAttributeAv($attributeAv); + } + $attribute->save(); + fclose($handle); + } + echo "colors attributes created with success\n"; + return $attribute; +} + +function clearTables() +{ + $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() + ->find(); + $productAssociatedContent->delete(); + + $categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create() + ->find(); + $categoryAssociatedContent->delete(); + + $featureProduct = Thelia\Model\FeatureProductQuery::create() + ->find(); + $featureProduct->delete(); + + $attributeCombination = Thelia\Model\AttributeCombinationQuery::create() + ->find(); + $attributeCombination->delete(); + + $feature = Thelia\Model\FeatureQuery::create() + ->find(); + $feature->delete(); + + $feature = Thelia\Model\FeatureI18nQuery::create() + ->find(); + $feature->delete(); + + $featureAv = Thelia\Model\FeatureAvQuery::create() + ->find(); + $featureAv->delete(); + + $featureAv = Thelia\Model\FeatureAvI18nQuery::create() + ->find(); + $featureAv->delete(); + + $attribute = Thelia\Model\AttributeQuery::create() + ->find(); + $attribute->delete(); + + $attribute = Thelia\Model\AttributeI18nQuery::create() + ->find(); + $attribute->delete(); + + $attributeAv = Thelia\Model\AttributeAvQuery::create() + ->find(); + $attributeAv->delete(); + + $attributeAv = Thelia\Model\AttributeAvI18nQuery::create() + ->find(); + $attributeAv->delete(); + + $category = Thelia\Model\CategoryQuery::create() + ->find(); + $category->delete(); + + $category = Thelia\Model\CategoryI18nQuery::create() + ->find(); + $category->delete(); + + $product = Thelia\Model\ProductQuery::create() + ->find(); + $product->delete(); + + $product = Thelia\Model\ProductI18nQuery::create() + ->find(); + $product->delete(); + + + $accessory = Thelia\Model\AccessoryQuery::create() + ->find(); + $accessory->delete(); + + $stock = \Thelia\Model\ProductSaleElementsQuery::create() + ->find(); + $stock->delete(); + + $productPrice = \Thelia\Model\ProductPriceQuery::create() + ->find(); + $productPrice->delete(); + + \Thelia\Model\ProductImageQuery::create()->find()->delete(); +} \ No newline at end of file diff --git a/install/import/brand.csv b/install/import/brand.csv new file mode 100644 index 000000000..00cdf654b --- /dev/null +++ b/install/import/brand.csv @@ -0,0 +1,7 @@ +"MILAN" +"MAGIS" +"OXYO" +"OFFUS" +"PLINK" +"PARRY" +"TOKO" diff --git a/install/import/categories.csv b/install/import/categories.csv new file mode 100644 index 000000000..109e5c0f0 --- /dev/null +++ b/install/import/categories.csv @@ -0,0 +1,5 @@ +"CATEGORIES FR";"CATEGORIES UK" +"Chaises";"Chairs" +"Tabourets";"Stools" +"Fauteuils";"Armchairs" +"Canapés";"Sofas" diff --git a/install/import/colors.csv b/install/import/colors.csv new file mode 100644 index 000000000..9b5ebcb6a --- /dev/null +++ b/install/import/colors.csv @@ -0,0 +1,13 @@ +"Bleu";"Blue" +"Jaune";"Yellow" +"Orange";"Orange" +"Rose";"Pink" +"Vert";"Green" +"Violet";"Purple" +"Rouge";"Red" +"Gris";"Gray" +"Noir";"Black" +"Beige";"Beige" +"Turquoise";"Turquoise" +"Marron";"Brown" +"Blanc";"White" diff --git a/install/import/images/PROD001-1.jpg b/install/import/images/PROD001-1.jpg new file mode 100755 index 000000000..c340872f7 Binary files /dev/null and b/install/import/images/PROD001-1.jpg differ diff --git a/install/import/images/PROD001-2.jpg b/install/import/images/PROD001-2.jpg new file mode 100755 index 000000000..d1eba51b9 Binary files /dev/null and b/install/import/images/PROD001-2.jpg differ diff --git a/install/import/images/PROD001-3.jpg b/install/import/images/PROD001-3.jpg new file mode 100755 index 000000000..89f69a766 Binary files /dev/null and b/install/import/images/PROD001-3.jpg differ diff --git a/install/import/images/PROD001-4.jpg b/install/import/images/PROD001-4.jpg new file mode 100755 index 000000000..94eb80ce9 Binary files /dev/null and b/install/import/images/PROD001-4.jpg differ diff --git a/install/import/images/PROD001-5.jpg b/install/import/images/PROD001-5.jpg new file mode 100755 index 000000000..3036b2196 Binary files /dev/null and b/install/import/images/PROD001-5.jpg differ diff --git a/install/import/images/PROD002-1.jpg b/install/import/images/PROD002-1.jpg new file mode 100755 index 000000000..f38d005e0 Binary files /dev/null and b/install/import/images/PROD002-1.jpg differ diff --git a/install/import/images/PROD002-2.jpg b/install/import/images/PROD002-2.jpg new file mode 100755 index 000000000..61a57c5ad Binary files /dev/null and b/install/import/images/PROD002-2.jpg differ diff --git a/install/import/images/PROD002-3.jpg b/install/import/images/PROD002-3.jpg new file mode 100755 index 000000000..845a26031 Binary files /dev/null and b/install/import/images/PROD002-3.jpg differ diff --git a/install/import/images/PROD002-4.jpg b/install/import/images/PROD002-4.jpg new file mode 100755 index 000000000..f9570ca9b Binary files /dev/null and b/install/import/images/PROD002-4.jpg differ diff --git a/install/import/images/PROD002-5.jpg b/install/import/images/PROD002-5.jpg new file mode 100755 index 000000000..bbc71b065 Binary files /dev/null and b/install/import/images/PROD002-5.jpg differ diff --git a/install/import/images/PROD002-6.jpg b/install/import/images/PROD002-6.jpg new file mode 100755 index 000000000..73a1698c8 Binary files /dev/null and b/install/import/images/PROD002-6.jpg differ diff --git a/install/import/images/PROD003-1.jpg b/install/import/images/PROD003-1.jpg new file mode 100755 index 000000000..f968e29d5 Binary files /dev/null and b/install/import/images/PROD003-1.jpg differ diff --git a/install/import/images/PROD003-2.jpg b/install/import/images/PROD003-2.jpg new file mode 100755 index 000000000..aed200077 Binary files /dev/null and b/install/import/images/PROD003-2.jpg differ diff --git a/install/import/images/PROD003-3.jpg b/install/import/images/PROD003-3.jpg new file mode 100755 index 000000000..ff5f6a90c Binary files /dev/null and b/install/import/images/PROD003-3.jpg differ diff --git a/install/import/images/PROD004-1.jpg b/install/import/images/PROD004-1.jpg new file mode 100755 index 000000000..f33005c77 Binary files /dev/null and b/install/import/images/PROD004-1.jpg differ diff --git a/install/import/images/PROD004-2.jpg b/install/import/images/PROD004-2.jpg new file mode 100755 index 000000000..d844637a7 Binary files /dev/null and b/install/import/images/PROD004-2.jpg differ diff --git a/install/import/images/PROD005-1.jpg b/install/import/images/PROD005-1.jpg new file mode 100755 index 000000000..5e2e29dec Binary files /dev/null and b/install/import/images/PROD005-1.jpg differ diff --git a/install/import/images/PROD005-2.jpg b/install/import/images/PROD005-2.jpg new file mode 100755 index 000000000..c236abedd Binary files /dev/null and b/install/import/images/PROD005-2.jpg differ diff --git a/install/import/images/PROD005-3.jpg b/install/import/images/PROD005-3.jpg new file mode 100755 index 000000000..51697517f Binary files /dev/null and b/install/import/images/PROD005-3.jpg differ diff --git a/install/import/images/PROD005-4.jpg b/install/import/images/PROD005-4.jpg new file mode 100755 index 000000000..4f5165509 Binary files /dev/null and b/install/import/images/PROD005-4.jpg differ diff --git a/install/import/images/PROD005-5.jpg b/install/import/images/PROD005-5.jpg new file mode 100755 index 000000000..81c791943 Binary files /dev/null and b/install/import/images/PROD005-5.jpg differ diff --git a/install/import/images/PROD005-6.jpg b/install/import/images/PROD005-6.jpg new file mode 100755 index 000000000..f48cac242 Binary files /dev/null and b/install/import/images/PROD005-6.jpg differ diff --git a/install/import/images/PROD006-1.jpg b/install/import/images/PROD006-1.jpg new file mode 100755 index 000000000..ac75a7ba2 Binary files /dev/null and b/install/import/images/PROD006-1.jpg differ diff --git a/install/import/images/PROD006-2.jpg b/install/import/images/PROD006-2.jpg new file mode 100755 index 000000000..fb72ae255 Binary files /dev/null and b/install/import/images/PROD006-2.jpg differ diff --git a/install/import/images/PROD006-3.jpg b/install/import/images/PROD006-3.jpg new file mode 100755 index 000000000..bd7f5721e Binary files /dev/null and b/install/import/images/PROD006-3.jpg differ diff --git a/install/import/images/PROD006-4.jpg b/install/import/images/PROD006-4.jpg new file mode 100755 index 000000000..394283e56 Binary files /dev/null and b/install/import/images/PROD006-4.jpg differ diff --git a/install/import/images/PROD006-5.jpg b/install/import/images/PROD006-5.jpg new file mode 100755 index 000000000..d258db936 Binary files /dev/null and b/install/import/images/PROD006-5.jpg differ diff --git a/install/import/images/PROD006-6.jpg b/install/import/images/PROD006-6.jpg new file mode 100755 index 000000000..982815847 Binary files /dev/null and b/install/import/images/PROD006-6.jpg differ diff --git a/install/import/images/PROD007-1.jpg b/install/import/images/PROD007-1.jpg new file mode 100755 index 000000000..fda1d2880 Binary files /dev/null and b/install/import/images/PROD007-1.jpg differ diff --git a/install/import/images/PROD007-2.jpg b/install/import/images/PROD007-2.jpg new file mode 100755 index 000000000..a784790cf Binary files /dev/null and b/install/import/images/PROD007-2.jpg differ diff --git a/install/import/images/PROD007-3.jpg b/install/import/images/PROD007-3.jpg new file mode 100755 index 000000000..30b5637ae Binary files /dev/null and b/install/import/images/PROD007-3.jpg differ diff --git a/install/import/images/PROD007-4.jpg b/install/import/images/PROD007-4.jpg new file mode 100755 index 000000000..00556c665 Binary files /dev/null and b/install/import/images/PROD007-4.jpg differ diff --git a/install/import/images/PROD008-1.jpg b/install/import/images/PROD008-1.jpg new file mode 100755 index 000000000..dc8e0bead Binary files /dev/null and b/install/import/images/PROD008-1.jpg differ diff --git a/install/import/images/PROD008-2.jpg b/install/import/images/PROD008-2.jpg new file mode 100755 index 000000000..173bed1aa Binary files /dev/null and b/install/import/images/PROD008-2.jpg differ diff --git a/install/import/images/PROD008-3.jpg b/install/import/images/PROD008-3.jpg new file mode 100755 index 000000000..790d8add6 Binary files /dev/null and b/install/import/images/PROD008-3.jpg differ diff --git a/install/import/images/PROD008-4.jpg b/install/import/images/PROD008-4.jpg new file mode 100755 index 000000000..ec4af28cc Binary files /dev/null and b/install/import/images/PROD008-4.jpg differ diff --git a/install/import/images/PROD008-5.jpg b/install/import/images/PROD008-5.jpg new file mode 100755 index 000000000..91e7ebaa0 Binary files /dev/null and b/install/import/images/PROD008-5.jpg differ diff --git a/install/import/images/PROD009-1.jpg b/install/import/images/PROD009-1.jpg new file mode 100755 index 000000000..3a143de1a Binary files /dev/null and b/install/import/images/PROD009-1.jpg differ diff --git a/install/import/images/PROD009-2.jpg b/install/import/images/PROD009-2.jpg new file mode 100755 index 000000000..b5ccde667 Binary files /dev/null and b/install/import/images/PROD009-2.jpg differ diff --git a/install/import/images/PROD009-3.jpg b/install/import/images/PROD009-3.jpg new file mode 100755 index 000000000..76d465a47 Binary files /dev/null and b/install/import/images/PROD009-3.jpg differ diff --git a/install/import/images/PROD010-1.jpg b/install/import/images/PROD010-1.jpg new file mode 100755 index 000000000..5f9df3fbb Binary files /dev/null and b/install/import/images/PROD010-1.jpg differ diff --git a/install/import/images/PROD010-2.jpg b/install/import/images/PROD010-2.jpg new file mode 100755 index 000000000..3fe504716 Binary files /dev/null and b/install/import/images/PROD010-2.jpg differ diff --git a/install/import/images/PROD010-3.jpg b/install/import/images/PROD010-3.jpg new file mode 100755 index 000000000..867361eb9 Binary files /dev/null and b/install/import/images/PROD010-3.jpg differ diff --git a/install/import/images/PROD010-4.jpg b/install/import/images/PROD010-4.jpg new file mode 100755 index 000000000..f9681b9bf Binary files /dev/null and b/install/import/images/PROD010-4.jpg differ diff --git a/install/import/images/PROD011-1.jpg b/install/import/images/PROD011-1.jpg new file mode 100755 index 000000000..8130598bc Binary files /dev/null and b/install/import/images/PROD011-1.jpg differ diff --git a/install/import/images/PROD011-2.jpg b/install/import/images/PROD011-2.jpg new file mode 100755 index 000000000..e37c4baaf Binary files /dev/null and b/install/import/images/PROD011-2.jpg differ diff --git a/install/import/images/PROD011-3.jpg b/install/import/images/PROD011-3.jpg new file mode 100755 index 000000000..ba4530c3c Binary files /dev/null and b/install/import/images/PROD011-3.jpg differ diff --git a/install/import/images/PROD011-4.jpg b/install/import/images/PROD011-4.jpg new file mode 100755 index 000000000..b749649d8 Binary files /dev/null and b/install/import/images/PROD011-4.jpg differ diff --git a/install/import/images/PROD012-1.jpg b/install/import/images/PROD012-1.jpg new file mode 100755 index 000000000..ff885661d Binary files /dev/null and b/install/import/images/PROD012-1.jpg differ diff --git a/install/import/images/PROD012-2.jpg b/install/import/images/PROD012-2.jpg new file mode 100755 index 000000000..c27fd1cbb Binary files /dev/null and b/install/import/images/PROD012-2.jpg differ diff --git a/install/import/images/PROD013-1.jpg b/install/import/images/PROD013-1.jpg new file mode 100755 index 000000000..729fe97f7 Binary files /dev/null and b/install/import/images/PROD013-1.jpg differ diff --git a/install/import/images/PROD014-1.jpg b/install/import/images/PROD014-1.jpg new file mode 100755 index 000000000..384b1939e Binary files /dev/null and b/install/import/images/PROD014-1.jpg differ diff --git a/install/import/images/PROD014-2.jpg b/install/import/images/PROD014-2.jpg new file mode 100755 index 000000000..42de512f5 Binary files /dev/null and b/install/import/images/PROD014-2.jpg differ diff --git a/install/import/images/PROD014-3.jpg b/install/import/images/PROD014-3.jpg new file mode 100755 index 000000000..0270dc868 Binary files /dev/null and b/install/import/images/PROD014-3.jpg differ diff --git a/install/import/images/PROD014-4.jpg b/install/import/images/PROD014-4.jpg new file mode 100755 index 000000000..e845a8838 Binary files /dev/null and b/install/import/images/PROD014-4.jpg differ diff --git a/install/import/images/PROD015-1.jpg b/install/import/images/PROD015-1.jpg new file mode 100755 index 000000000..f99e9e275 Binary files /dev/null and b/install/import/images/PROD015-1.jpg differ diff --git a/install/import/images/PROD015-2.jpg b/install/import/images/PROD015-2.jpg new file mode 100755 index 000000000..b56a13951 Binary files /dev/null and b/install/import/images/PROD015-2.jpg differ diff --git a/install/import/images/PROD016-1.jpg b/install/import/images/PROD016-1.jpg new file mode 100755 index 000000000..3aff2648a Binary files /dev/null and b/install/import/images/PROD016-1.jpg differ diff --git a/install/import/images/PROD017-1.jpg b/install/import/images/PROD017-1.jpg new file mode 100755 index 000000000..1a620ab47 Binary files /dev/null and b/install/import/images/PROD017-1.jpg differ diff --git a/install/import/images/PROD017-2.jpg b/install/import/images/PROD017-2.jpg new file mode 100755 index 000000000..82a20f1fb Binary files /dev/null and b/install/import/images/PROD017-2.jpg differ diff --git a/install/import/images/PROD017-3.jpg b/install/import/images/PROD017-3.jpg new file mode 100755 index 000000000..d476eb773 Binary files /dev/null and b/install/import/images/PROD017-3.jpg differ diff --git a/install/import/images/PROD017-4.jpg b/install/import/images/PROD017-4.jpg new file mode 100755 index 000000000..b3a3e4707 Binary files /dev/null and b/install/import/images/PROD017-4.jpg differ diff --git a/install/import/images/PROD018-1.jpg b/install/import/images/PROD018-1.jpg new file mode 100755 index 000000000..cefa9992e Binary files /dev/null and b/install/import/images/PROD018-1.jpg differ diff --git a/install/import/images/PROD019-1.jpg b/install/import/images/PROD019-1.jpg new file mode 100755 index 000000000..2e45bb27f Binary files /dev/null and b/install/import/images/PROD019-1.jpg differ diff --git a/install/import/images/PROD019-2.jpg b/install/import/images/PROD019-2.jpg new file mode 100755 index 000000000..9b47f6ea1 Binary files /dev/null and b/install/import/images/PROD019-2.jpg differ diff --git a/install/import/images/PROD019-3.jpg b/install/import/images/PROD019-3.jpg new file mode 100755 index 000000000..02aa975da Binary files /dev/null and b/install/import/images/PROD019-3.jpg differ diff --git a/install/import/images/PROD019-4.jpg b/install/import/images/PROD019-4.jpg new file mode 100755 index 000000000..fad8bbf59 Binary files /dev/null and b/install/import/images/PROD019-4.jpg differ diff --git a/install/import/images/PROD019-5.jpg b/install/import/images/PROD019-5.jpg new file mode 100755 index 000000000..0e2377b8c Binary files /dev/null and b/install/import/images/PROD019-5.jpg differ diff --git a/install/import/images/PROD020-1.jpg b/install/import/images/PROD020-1.jpg new file mode 100755 index 000000000..14b7ae55b Binary files /dev/null and b/install/import/images/PROD020-1.jpg differ diff --git a/install/import/images/PROD021-1.jpg b/install/import/images/PROD021-1.jpg new file mode 100755 index 000000000..5cd5e27ed Binary files /dev/null and b/install/import/images/PROD021-1.jpg differ diff --git a/install/import/images/PROD021-2.jpg b/install/import/images/PROD021-2.jpg new file mode 100755 index 000000000..119afa3be Binary files /dev/null and b/install/import/images/PROD021-2.jpg differ diff --git a/install/import/images/PROD021-3.jpg b/install/import/images/PROD021-3.jpg new file mode 100755 index 000000000..0b4470d3c Binary files /dev/null and b/install/import/images/PROD021-3.jpg differ diff --git a/install/import/images/PROD021-4.jpg b/install/import/images/PROD021-4.jpg new file mode 100755 index 000000000..0cffa4dea Binary files /dev/null and b/install/import/images/PROD021-4.jpg differ diff --git a/install/import/images/PROD022-1.jpg b/install/import/images/PROD022-1.jpg new file mode 100755 index 000000000..72eb89cfe Binary files /dev/null and b/install/import/images/PROD022-1.jpg differ diff --git a/install/import/images/PROD022-2.jpg b/install/import/images/PROD022-2.jpg new file mode 100755 index 000000000..85292d60d Binary files /dev/null and b/install/import/images/PROD022-2.jpg differ diff --git a/install/import/images/PROD022-3.jpg b/install/import/images/PROD022-3.jpg new file mode 100755 index 000000000..e564ed1b6 Binary files /dev/null and b/install/import/images/PROD022-3.jpg differ diff --git a/install/import/images/PROD022-4.jpg b/install/import/images/PROD022-4.jpg new file mode 100755 index 000000000..09d39fd35 Binary files /dev/null and b/install/import/images/PROD022-4.jpg differ diff --git a/install/import/images/PROD022-5.jpg b/install/import/images/PROD022-5.jpg new file mode 100755 index 000000000..f47219289 Binary files /dev/null and b/install/import/images/PROD022-5.jpg differ diff --git a/install/import/images/PROD023-1.jpg b/install/import/images/PROD023-1.jpg new file mode 100755 index 000000000..e645f5eb9 Binary files /dev/null and b/install/import/images/PROD023-1.jpg differ diff --git a/install/import/images/PROD023-2.jpg b/install/import/images/PROD023-2.jpg new file mode 100755 index 000000000..ad438c981 Binary files /dev/null and b/install/import/images/PROD023-2.jpg differ diff --git a/install/import/images/PROD023-3.jpg b/install/import/images/PROD023-3.jpg new file mode 100755 index 000000000..ccafdb7fa Binary files /dev/null and b/install/import/images/PROD023-3.jpg differ diff --git a/install/import/images/PROD023-4.jpg b/install/import/images/PROD023-4.jpg new file mode 100755 index 000000000..a2fc55786 Binary files /dev/null and b/install/import/images/PROD023-4.jpg differ diff --git a/install/import/images/PROD023-5.jpg b/install/import/images/PROD023-5.jpg new file mode 100755 index 000000000..bf67ea4b0 Binary files /dev/null and b/install/import/images/PROD023-5.jpg differ diff --git a/install/import/images/PROD023-6.jpg b/install/import/images/PROD023-6.jpg new file mode 100755 index 000000000..5d037669b Binary files /dev/null and b/install/import/images/PROD023-6.jpg differ diff --git a/install/import/images/PROD024-1.jpg b/install/import/images/PROD024-1.jpg new file mode 100755 index 000000000..7f3874205 Binary files /dev/null and b/install/import/images/PROD024-1.jpg differ diff --git a/install/import/images/PROD024-2.jpg b/install/import/images/PROD024-2.jpg new file mode 100755 index 000000000..fcd4bd587 Binary files /dev/null and b/install/import/images/PROD024-2.jpg differ diff --git a/install/import/images/PROD024-3.jpg b/install/import/images/PROD024-3.jpg new file mode 100755 index 000000000..1d0c8deef Binary files /dev/null and b/install/import/images/PROD024-3.jpg differ diff --git a/install/import/images/PROD024-4.jpg b/install/import/images/PROD024-4.jpg new file mode 100755 index 000000000..7ff3957c1 Binary files /dev/null and b/install/import/images/PROD024-4.jpg differ diff --git a/install/import/images/PROD024-5.jpg b/install/import/images/PROD024-5.jpg new file mode 100755 index 000000000..53a63564c Binary files /dev/null and b/install/import/images/PROD024-5.jpg differ diff --git a/install/import/images/PROD025-1.jpg b/install/import/images/PROD025-1.jpg new file mode 100755 index 000000000..54fa325e5 Binary files /dev/null and b/install/import/images/PROD025-1.jpg differ diff --git a/install/import/images/PROD025-2.jpg b/install/import/images/PROD025-2.jpg new file mode 100755 index 000000000..fd3ba1611 Binary files /dev/null and b/install/import/images/PROD025-2.jpg differ diff --git a/install/import/images/PROD025-3.jpg b/install/import/images/PROD025-3.jpg new file mode 100755 index 000000000..6ec0c96ef Binary files /dev/null and b/install/import/images/PROD025-3.jpg differ diff --git a/install/import/images/PROD026-1.jpg b/install/import/images/PROD026-1.jpg new file mode 100755 index 000000000..96bb2b392 Binary files /dev/null and b/install/import/images/PROD026-1.jpg differ diff --git a/install/import/images/PROD027-1.jpg b/install/import/images/PROD027-1.jpg new file mode 100755 index 000000000..9ab635023 Binary files /dev/null and b/install/import/images/PROD027-1.jpg differ diff --git a/install/import/images/PROD028-1.jpg b/install/import/images/PROD028-1.jpg new file mode 100755 index 000000000..1a166e91b Binary files /dev/null and b/install/import/images/PROD028-1.jpg differ diff --git a/install/import/images/PROD029-1.jpg b/install/import/images/PROD029-1.jpg new file mode 100755 index 000000000..e25b56f18 Binary files /dev/null and b/install/import/images/PROD029-1.jpg differ diff --git a/install/import/images/PROD030-1.jpg b/install/import/images/PROD030-1.jpg new file mode 100755 index 000000000..731d82897 Binary files /dev/null and b/install/import/images/PROD030-1.jpg differ diff --git a/install/import/images/PROD030-2.jpg b/install/import/images/PROD030-2.jpg new file mode 100755 index 000000000..15ecbef26 Binary files /dev/null and b/install/import/images/PROD030-2.jpg differ diff --git a/install/import/images/PROD030-3.jpg b/install/import/images/PROD030-3.jpg new file mode 100755 index 000000000..8f3d9eb54 Binary files /dev/null and b/install/import/images/PROD030-3.jpg differ diff --git a/install/import/images/PROD030-4.jpg b/install/import/images/PROD030-4.jpg new file mode 100755 index 000000000..2d402e8d9 Binary files /dev/null and b/install/import/images/PROD030-4.jpg differ diff --git a/install/import/products.csv b/install/import/products.csv new file mode 100644 index 000000000..b085feee2 --- /dev/null +++ b/install/import/products.csv @@ -0,0 +1,35 @@ +"REF";"TITRE UK";"CHAPO UK";"CHAPO FR";"DESCRIPTIF UK";"DESCRIPTIF FR";"POSTSCRIPTUM UK";"POSTSCRIPTUM FR";"PRIX";"PRIX2";"PHOTO";"BRAND";"COULEUR UK";"CATEGORIE" +"PROD001";"Horatio";"Contemporary atypical chair";"Chaise contemporaine hors normes";"Its design is based on a very simple idea : atypical aesthetics for an everyday use. You may even choose to combine the various colours ! A specific look that will happily and impertinently fit with your furniture. ";"Son design est issu d'une idée très simple: un esthétique hors du commun pour un usage de tous les jours. On peut même choisir de combiner les différents coloris! Un look qui se mêle avec bonheur et impertinence à votre mobilier. +";"Dimensions : Width : 20'' – Depth: 19'' – Height: 42''";"Dimensions : Larg 52 cm - Prof 50 cm - Haut 108 cm";223;199;"PROD001-1.jpg;PROD001-2.jpg;PROD001-3.jpg;PROD001-4.jpg";"MILAN";"blue;pink;red;green;purple";"Chairs" +"PROD002";"Travis";"Ergonomic & affordable";"Ergonomique et économique";"Ergonomic, affordable, comfortable, stackable, easily dismantled, this little stool became a cult item. Decorative feature or occasional seat, it suits perfectly any room in the house. ";"Ergonomique, économique, confortable, empilable, démontable, ce petit tabouret est devenu un objet culte. Elément de décor ou siège d'appoint, il a sa place dans toute la maison. +";"Dimensions : Diam. 11'' – Height: 17''";"Dimensions : Diam 30 cm - Haut 45 cm";25;19;"PROD002-1.jpg;PROD002-2.jpg;PROD002-3.jpg;PROD002-4.jpg;PROD002-5.jpg;PROD002-6.jpg";"MAGIS";"blue;orange;yellow;pink;purple;green";"Stools" +"PROD003";"Stacy";"A successfull mix";"Un mariage réussi";"The ''Stacy'' armchair brings a taste of playfulness in the design's world for more than 20 years ! The successfull mix of French Regence style and ultra modern materials creates a strong charismatic personality. ";"Le fauteuil Stacy apporte une note de fantaisie dans le monde du design depuis plus de 20 ans ! Sa personnalité forte et charismatique s'exprime au travers de cette association de style Régence et de matériaux ultramoderne. ";"Dimensions : Width :44'' – Depth:31'' – Height: 42'' . Sitting : width : 25''– Height : 16'' . Armrests height : 27''";"Dimensions : Larg 114 cm x Prof 80 cm x H 108 cm - Assise : larg 65 cm x H 42 cm - Accoudoirs : H 69 cm";653;610;"PROD003-1.jpg;PROD003-2.jpg;PROD003-3.jpg;";"MILAN";"blue;purple;green";"Armchairs" +"PROD004";"Scarlett";"A timeless treasure";"Un trésor intemporel";"Treasured and timeless styling characterizes the luxury ''Scarlett'' Armchair. It will instantly add a dash of refined appeal to any living space. Beneath the luxurious fabric cover is a solid wood frame, ensuring that this piece will be passed on from generation to generation. ";"Un style précieux et intemporel caractérise la luxueuse banquette Scarlett. Elle apporte immédiatement une touche de raffinement à n'importe quel salon. Sous l'étoffe précieuse, un solide châssis bois vous assure que cette pièce traversera les époques et les générations. ";"Dimensions : Width :65'' – Depth:31''– Height: 38''";"Dimensions : Larg 165 cm x Prof 80 cm x H 95 cm";956;899;"PROD004-1.jpg;PROD004-2.jpg";"OXYO";"gray;black";"Armchairs" +"PROD005";"Owen";"An eye-catching armchair";"Un fauteuil surprenant";"Get a look at the future – retro style - with our cutout ''Owen'' armchair ! Eye-catching and incredibly fun, this armchair is a must-have for today's hottest living space ! ";"Revisitez le futur avec une note retro grâce à notre fauteuil Owen! Spectaculaire et incroyablement fun, ce fauteuil est incontournable pour un salon moderne et branché ! ";"Dimensions : Width :30'' – Depth:31''– Height: 35''";"Dimensions : Larg 75 cm - Prof 80 cm - Haut 90 cm";395;;"PROD005-1.jpg;PROD005-2.jpg;PROD005-3.jpg;PROD005-4.jpg;PROD005-5.jpg;PROD005-6.jpg";"OXYO";"blue;purple;green;pink;red;orange;";"Armchairs" +"PROD006";"Nigel";"A comfortable beauty";"Une beauté confortable";"This comfortable beauty does great solo as a lounger or in a book nook. With the ''Nigel'' sofa, you will get hours of cozy relaxation. This oversized seat is the ultimate lounger but the pure design still keeps it modern and hip. ";"La beauté confortable du sofa Nigel permet tous les solos dans votre salon ou votre bibliothèque. Relaxez vous tranquilement avec le canapé Nigel. Ce siège généreux est l'expression même du fauteuil mais ses lignes pures lui assurent un style moderne et tendance. ";"Dimensions: Width : 48"" - Depth : 32"" - Height : 28"" – 17"" seat Height";"Dimensions : Larg 120 cm – Prof  80 cm – Haut. 70 cm . Hauteur d'assise : 40 cm";638;;"PROD006-1.jpg;PROD006-2.jpg;PROD006-3.jpg;PROD006-4.jpg;PROD006-5.jpg;PROD006-6.jpg";"OXYO";"blue;beige;purple;green;pink;turquoise";"Sofas" +"PROD007";"Heathcliff";"A unique style";"Un style unique";"Provide a rich texture to any living space thanks to the tufting and velvet of the ''Heathcliff'' sofa. Arched roll arms and vibrant colours add to the fun and unique style of this sofa. ";"Enrichissez votre intérieur de velours et de textures capitonnées du canapé Heathcliff. Les accoudoirs arrondis en finition cloutée et la gamme de couleurs acidulées apportent un style et une fantaisie unique à ce sofa. ";"Dimensions: Width : 92"" - Depth : 43"" - Height : 36""";"Dimensions : Larg 230 cm – Prof. 110 cm – Haut. 90 cm";1120;;"PROD007-1.jpg;PROD007-2.jpg;PROD007-3.jpg;PROD007-4.jpg;";"OFFUS";"turquoise;blue;pink;purple";"Sofas" +"PROD008";"Wilson";"Pure luxury !";"Le luxe à l'état pur !";"Choose our ''Wilson'' armchair and surround yourself in luxury. You will appreciate it's high armrests that will keep you nestled in comfort. Beautiful coloured leather upholstery makes a fashion-forward design statement. ";"Adoptez notre fauteuil Wilson et plongez dans le luxe. Vous apprécierez ses hauts accoudoirs qui vous envelopperont de confort et de douceur. L'habillage en cuir de couleur vive en fait une pièce de design avant-gardiste. ";"Dimensions : Width : 38"" - Depth : 36"" - Height : 34""";"Dimensions : larg 95 cm – Prof. 90 cm – Haut. 90 cm";489;;"PROD008-1.jpg;PROD008-2.jpg;PROD008-3.jpg;PROD008-4.jpg;PROD008-5.jpg;";"PLINK";"blue;green;pink;purple;brown;";"Armchairs" +"PROD009";"Zoe";"An exceptional combination";"Une union exceptionnelle";"Contemporary ''Zoe'' armchair is an exceptional combination of function and design. +The seating is generously cushioned for comfort. Contoured, wrap-around back offers optimal support. The brushed stainless steel base ensures stability. +Swivel feature for added function. ";"Zoe est un fauteuil contemporain qui combine de manière exceptionnelle fonctionnalité et design. L'assise est garnie d'un coussin généreux pour plus de confort. Le dossier enveloppant offre un appui optimal. La stabilité de l'ensemble est assurée par une base en inox brossé. Siège pivotant. ";"Dimensions : Width : 30'' – Depth : 27'' – height : 31''";"Dimensions : Larg. 75 cm – Prof. 69 cm – Haut. 80 cm";520;;"PROD009-1.jpg;PROD009-2.jpg;PROD009-3.jpg";"PLINK";"blue;purple;orange";"Armchairs" +"PROD010";"Sigmund";"A fun project";"Un projet fou";"The contrast of a vintage couch and modern colours provides a really fun project called ''Sigmund'' ! It will instantly add a dash of impertinence for any hip living place. ";"Le projet fantastique appelé Sigmund provient d'un contraste étonnant entre un canapé vintage et un éventail de couleurs moderne. Ce canapé apportera immédiatement une touche d'impertinence à n'importe quel salon branché. ";"Dimensions: Width : 92"" - Depth : 43"" - Height : 36""";"Dimensions : Larg 230 cm – Prof. 110 cm – Haut. 90 cm";834;;"PROD010-1.jpg;PROD010-2.jpg;PROD010-3.jpg;PROD010-4.jpg";"OFFUS";"blue;purple;red;orange";"Armchairs ; Sofas" +"PROD011";"Tina";"The little plastic chair";"La petite chaise en plastique";"This little ''Tina'' plastic chair will become your new red hot favourite thanks to its efficient design. Stackable and made of recyclable material, Tina suits perfectly any room in the house ! ";"L'efficacité du design de cette petite chaise en plastique Tina en fera vite votre favorite. Empilable et recyclable, Tina se glissera parfaitement dans n'importe quelle pièce de votre maison ! ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm ";75;;"PROD011-1.jpg;PROD011-2.jpg;PROD011-3.jpg;PROD011-4.jpg";"PARRY";"blue;orange;red;purple";"Chairs" +"PROD012";"Victoria";"Pure lines";"Des lignes éûrées";"A successfull combination of Regence style and ultra modern material. The pure lines of the ''Victoria'' armchair together with its translucent brilliance make a fashion-forward design statement. ";"Un mariage réussit du style Régence et de matériaux ultra modernes. Les lignes pures de la chaise Victoria associées à la brillance translucide de sa matière en font une pièce de design avant-gardiste. ";"Dimensions : Width :44'' – Depth:31'' – Height: 42'' . Sitting : width : 25''– Height : 16'' . Armrests height : 27''";"Dimensions : Larg 114 cm x Prof 80 cm x H 108 cm - Assise : larg 65 cm x H 42 cm - Accoudoirs : H 69 cm";138;;"PROD012-1.jpg;PROD012-2.jpg";"MILAN";"black";"Armchairs" +"PROD013";"Violet";"A beautifull classic";"Une beauté classique";"A new edition of a classic. Beneath a beautiful colorfull leather, a strong walnut wood frame. You will appreciate the luxurious stylish details of the ''Violet'' armless chair. ";"La réédition d'un classique. Sous un superbe cuir aux couleurs chatoyantes, une solide structure en noyer. Vous apprécierez les détails stylistiques luxueux de notre chaise Violet. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";98;;"PROD013-1.jpg";"MAGIS";"Gray";"Chairs" +"PROD014";"Sally";"Contemporary atypical chair";"Chaise contemporaine hors normes";"Contemporary atypical chair. The atypical sitting of the ''Sally '' chair will nestled you in confort. Play with the vibrant colours range to create a unique dining room. ";"Chaise contemporaine hors normes. L'assise surprenante de la chaise Sally vous enveloppera de confort. Amusez vous avec l'éventail de couleurs lumineuses pour créer une salle à manger unique. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";112;;"PROD014-1.jpg;PROD014-2.jpg;PROD014-3.jpg;PROD014-4.jpg";"PARRY";"blue;purple;orange;yellow";"Chairs" +"PROD015";"Oliver";"Comfort & Design";"Confort et Design";"Surround yourself in ultra modern luxury with the ''Oliver'' armchair and get a look at the future ! Eye-catching, this unique combination of comfort and design is a must-have for today's book nook. ";"Abandonnez vous à un univers de luxe ultra moderne avec le fauteuil Oliver et voyagez dans le futur ! Cette combinaison unique de confort et de design est spectaculaire. Un élément incontournable pour votre bibliothèque. ";"Dimensions : Width : 30'' – Depth : 27'' – height : 31''";"Dimensions : Larg. 75 cm – Prof. 69 cm – Haut. 80 cm";340;;"PROD015-1.jpg;PROD015-2.jpg;";"MAGIS";"white;black";"Armchairs;Chairs" +"PROD016";"Lexie";"A modern style";"Un style moderne";"Demonstrate your flair for modern style with our ''Lexie'' chair in your dining room. A rectangular cushioned back offers a contemporary feel, while the comfortable seat provides complete comfort. ";"Montrez que vous avez le sens de la modernité en choisissant la chaise ''Lexie'' pour votre salle à manger. Le coussin rectangulaire sur le dossier apporte une touche contemporaine. L'assise généreuse apporte un confort complet. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 40''";"Dimensions : larg. 50 cm – Prof. 60 cm – Haut. 100 cm";159;;"PROD016-1.jpg";"PLINK";"Beige";"Chairs" +"PROD017";"Flynn";"A touch of retro vibe";"Un petit air rétro";"If your destination is up-to-date décor with a touch of retro vibe, look no further than our ''Flynn'' sofa. Sleek, low track arms and high tapering legs give this piece a mid-century flavor. The vibrant tones of the woven upholstery will easily blend with any interior décor. ";"Si vous recherchez une décoration actuelle avec une touche rétro, n'allez pas plus loin et opter pour notre canapé ''Flynn''. Ce canapé a un petit air des années 50 grâce à ses accoudoirs bas, ses pieds allongés et ses lignes pures. Les couleurs chatoyantes de son revêtement en laine lui permettent de se fondre dans tous les intérieurs. ";"Dimensions : Width : 89'' – Depth : 37'' – Height : 36''";"Dimensions : Larg. 225 cm – Prof. 95 cm – Haut. 90 cm";1299;;"PROD017-1.jpg;PROD017-2.jpg;PROD017-3.jpg;PROD017-4.jpg";"OFFUS";"blue;green;red;purple";"Sofas" +"PROD018";"Emily";"A old-world feel";"Une touche d'histoire";"Our ''Emily'' armlesschair adds a touch of a old-world feel to your space. Perfect for when defining the seating space in a larger room. A medium wood finish sets off the delicate embellishments at the base, while the luxurous upholstery keeps the look fresh. The cushions guarantee that this is a chair worth relaxing in, not just admiring from afar. ";"La chaise ''Emily'' apporte une touche d'histoire à votre intérieur. Elle est parfaite pour structurer votre espace, notamment dans une grande pièce. Les finitions bois font la part belle à de délicates arabesques, tandis que le luxueux revêtement apporte un look frais. Cette chaise n'est pas destinée à la figuration grâce à la mousse confortable de l'assise. ";"Dimensions : Width : 33'' – Depth : 27'' – Height : 40''";"Dimensions : Larg. 85 cm – Prof. 69 cm – Haut. 100 cm";690;;"PROD018-1.jpg";"PARRY";"red";"Armchairs" +"PROD019";"Edgar";"A special spot";"Un endroit à part";"A special spot for reading, lounging or chatting, our '' Edgar '' armchair has no reservations when it comes to style. The design starts with mid-century modern elements like lean arms, while the brushed stainless steel base ensures stability. Swivel feature for added function. ";"Un endroit spécial où lire, rêver ou discuter, notre fauteuil ''Edgar'' n'a pas de limite quand il s'agit de style. Son design part d'éléments contemporains comme ses accoudoirs bas et fins, tandis que sa base en inox brossé assure la stabilité de l'ensemble. Siège pivotant. ";"Dimensions : Width : 33'' – Depth : 27'' – Height : 40''";"Dimensions: Larg. 85 cm – Prof. 69 cm – Haut. 100 cm";275;;"PROD019-1.jpg;PROD019-2.jpg;PROD019-3.jpg;PROD019-4.jpg;PROD019-5.jpg";"TOKO";"blue;yellow;orange;pink;purple";"Armchairs" +"PROD020";"Pamela";"Clean lines";"Des lignes pures";"By making our ''Pamela'' chair a centerpiece of your dining area, you'll demonstrate your eye for clean lines and comfortable seating. The contemporary touches of this chair are provided by the light brown wool, a flared seat back and slightly curved wood back legs. The color of the uphostery is the perfect complement to the wood finish of the chair legs. ";"Choisissez notre chaise '' Pamela'' comme pièce maitresse de votre salle à manger et faites la démonstration de votre maitrise des lignes épurées et du confort d'assise. L'allure contemporaine de cette chaise provient de la laine beige, du dossier légèrement évasé et des pieds en bois arrières délicatement incurvés. La couleur du revêtement fait parfaitement écho à la finition bois des pieds. Dimensions : larg. 50 cm – Prof. 60 cm – Haut. 100 cm";"Dimensions : Width : 19'' – Depth : 23'' – Height : 40''";"Dimensions : Width : 19'' – Depth : 23'' – Height : 40''";189;;"PROD020-1.jpg";"OFFUS";"brown";"Chairs" +"PROD021";"Courtney";"Mil madness";"Douce folie";"Add a dash of mild madness to your kitchen ! Eye-catching, this ''Courtney'' armless chair is a must-have for hip dining area.";"Mettez une touche de douce folie dans votre cuisine ! Surprenante, notre chaise ''Courtney'' est incontournable pour un coin repas branché. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm ";89;;"PROD021-1.jpg;PROD021-2.jpg;PROD021-3.jpg;PROD021-4.jpg";"TOKO";"blue;orange;green;purple";"Chairs" +"PROD022";"Barbara";"An amazing look";"Un look détonnant";"An amazing look for our ''Barbara'' chair ! A cut-out oval in the back provides a distinctive character, while the lively range of colours and the mat finish makes a big style statement. Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Un look hors du commun pour la chaise ''Barbara'' ! L'ouverture oval du dossier apporte une personnalité toute particulière tandis que la large gamme de couleurs vives et le rendu mat provoque un vrai effet de style. Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm ";"Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm ";122;;"PROD022-1.jpg;PROD022-2.jpg;PROD022-3.jpg;PROD022-4.jpg;PROD022-5.jpg";"MAGIS";"blue;turquoise;yellow;orange;red";"Chairs" +"PROD023";"Haley";"An armless chair coming from outer space !";"Une chaise cosmique !";"This ''Haley'' amazing chair is as light as paper but sturdy as steel. Play with the vibrant colours range to create a unique dining area. ";"La chaise ''Haley'' est étonnante : légère comme le papier mais solide comme l'acier. Jouez avec la gamme de couleurs vibrantes pour composer un espace repas unique.";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm ";93;;"PROD023-1.jpg;PROD023-2.jpg;PROD023-3.jpg;PROD023-4.jpg;PROD023-5.jpg;PROD023-6.jpg";"MILAN";"purple;green;pink;red;orange;turquoise";"Chairs" +"PROD024";"Kyle";"A modern silhouette";"Un look moderne";"The modern silhouette of the ''Kyle'' sofa features cantilevered legs in a mirror chrome finish and pillow armrests. The button-tufted seat and back cushions highlight the detailed craftsmanship. ";"Le canapé ''Kyle'' offre une silhouette moderne grâce à ses pieds chromés en porte-à-faux et ses accoudoirs moelleux. L'assise et le dossier capitonnés mettent en valeur le travail précis de l'artisan.";"Dimensions: Width : 92"" - Depth : 43"" - Height : 36""";"Dimensions : Larg 230 cm – Prof. 110 cm – Haut. 90 cm";1799;;"PROD024-1.jpg;PROD024-2.jpg;PROD024-3.jpg;PROD024-4.jpg;PROD024-5.jpg";"TOKO";"blue;pink;red;green;purple";"Sofas" +"PROD025";"Kenny";"A fresh take on a classic chair ";"Un classique revisité";"Chic design elements and a lovely pattern bring cool interest to this ''Kenny'' chair. The well-lofted seat cushion offers ultimate comfort and support.";"Des éléments de design élégants et un motif chic apporte un nouvel intérêt à notre chaise ''Kenny''. Un coussin d'assise bien positionné offre un confort suprême.";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";299;;"PROD025-1.jpg;PROD025-2.jpg;PROD025-3.jpg";"PLINK";"blue;purple;green";"Chairs" +"PROD026";"Stuart";"A masterpiece of furniture design";"Une pièce de designer !";"Get the on-trend look of modern masterpieces of furniture design with our ''Stuart'' chair. Paying homage to the classic design, this piece has an architecturally inspired silhouette with its sculptural wood frame and the clean lines of seat and back cushions. The crisp white hue will blend easily with a range of color schemes. ";"Offrez vous le look branché d'une grande pièce de designer avec la chaise ''Stuart''. Rendant hommage aux classiques du Design, cette chaise a une silhouette inspirée de l'architecture par son cadre bois sculptural et par les lignes pures de son assise et de son dossier. La fraiche nuance de blanc se fondera facilement dans toutes les harmonies de couleurs.";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";189;;"PROD026-1.jpg";"PLINK";"white";"Chairs" +"PROD027";"Marie-Claire";"A naturally appealing";"Une sobre élégance";"There's no denying the naturally appealing of our Marie-Claire chair! Its organic feeling is enhanced by the pretty wood veneers and faux leather upholstery, adding rustic charm and comfort.";"On ne peut nier l'élégance sobre de notre chaise Marie-Claire. Son allure naturelle est rehaussée par les finitions bois et le revêtement imitation cuir ajoute à son charme rustique et son confort.";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";104;;"PROD027-1.jpg";"TOKO";"green";"Chairs" +"PROD028";"Leela";"Contemporary fun chair";"Une fantaisie contemporaine";"At once contemporary and chic, The ''Leela'' chair makes your strong sense of personal style evident. Stylish, easy-clean, leather-like upholstery makes the cut-out in the back more stunning in the light of its vibrant yellow.";"Tout à la fois chic et contemporaine, la chaise ''Leela'' rend votre sens du style évident. Le revêtement en similicuir, facile d'entretien met en valeur l'ouverture du dossier par son jaune lumineux.";"Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm ";144;;"PROD028-1.jpg";"MILAN";"yellow";"Chairs;Armchairs" +"PROD029";"Nibbler";"A modern bar stool";"Un tabouret de bar moderne";"If you're looking for a chic, counter height stool that features clean lines and a modern sensibility, look no further than our ''Nibbler'' stool. A chrome-finished base, oval footrest and adjustable, gas-lift mechanism add to its modern look.";"Si vous recherchez un tabouret haut et chic, n'allez pas plus loin que notre tabouret ''Nibbler'' avec ses lignes pures et sa modernité. Une base chromée, un repose-pieds oval ajustable et un mécanisme à gaz ajoute à son look moderne.";"Dimensions : Width : 19'' – Depth : 18'' – Height : 29''";"Dimensions : Larg 50 cm – Prof. 45 cm – Haut. 75 cm";78;;"PROD029-1.jpg";"MAGIS";"black";"Stools" +"PROD030";"Ron";"Get a look at the futur";"Une incursion dans le futur";"Get a look at the future — retro style — with our ''Ron'' bar stool! The contemporary design of the seating with a cut-out oval in the back for distinctive character, while the lively range of colours and high gloss make a big style statement. A chrome-finished base, oval footrest and adjustable, gas-lift mechanism add to the fresh look. Eye-catching and fun, the ''ron'' stool is a must-have for today's hottest dining area and bars. ";"Revisitez le futur avec une note retro grâce au tabouret de bar ''Ron''! Le design contemporain de ce siège grâce à l'ouverture ovale dans son dossier et une large gamme de couleurs vives. Son rendu glossy lui donne un style tout particulier. Une base chromée, un repose-pieds oval ajustable et un mécanisme à gaz ajoute à son look moderne. Surprenant et joyeux, le tabouret ''Ron'' est un incontournable des coin repas et des bars les plus branchés";"Dimensions : Width : 19'' – Depth : 18'' – Height : 29''";"Dimensions : Larg 50 cm – Prof. 45 cm – Haut. 75 cm";96;;"PROD030-1.jpg;PROD030-2.jpg;PROD030-3.jpg;PROD030-4.jpg;";"OFFUS";"blue;yellow;orange;purple";"Stools" diff --git a/install/insert.sql b/install/insert.sql index d91035382..df252d366 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1,6 +1,6 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`date_format`,`time_format`,`datetime_format`,`decimal_separator`,`thousands_separator`,`decimals`,`by_default`,`created_at`,`updated_at`)VALUES -(1, 'Français', 'fr', 'fr_FR', '', 'd/m/Y', 'H:i:s', 'd/m/y H:i:s', ',', ' ', '2', '1', NOW(), NOW()), -(2, 'English', 'en', 'en_US', '', 'm-d-Y', 'h:i:s', 'm-d-Y h:i:s', '.', ' ', '2', '0', NOW(), NOW()), +(1, 'Français', 'fr', 'fr_FR', '', 'd/m/Y', 'H:i:s', 'd/m/y H:i:s', ',', ' ', '2', '0', NOW(), NOW()), +(2, 'English', 'en', 'en_US', '', 'm-d-Y', 'h:i:s', 'm-d-Y h:i:s', '.', ' ', '2', '1', NOW(), NOW()), (3, 'castellano', 'es', 'es_ES', '', 'm-d-Y', 'h:i:s', 'm-d-Y h:i:s', ',', '.', '2', '0', NOW(), NOW()), (4, 'Italiano', 'it', 'it_IT', '', 'd/m/Y', 'H:i:s', 'd/m/y H:i:s', ',', ' ', '2', '0', NOW(), NOW()); @@ -13,16 +13,34 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat ('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()), ('default_images_quality_percent', '75', 0, 0, NOW(), NOW()), ('original_image_delivery_mode', 'symlink', 0, 0, NOW(), NOW()), +('original_document_delivery_mode', 'symlink', 0, 0, NOW(), NOW()), ('images_library_path', 'local/media/images', 0, 0, NOW(), NOW()), +('documents_library_path', 'local/media/documents', 0, 0, NOW(), NOW()), ('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()), +('document_cache_dir_from_web_root', 'cache/documents', 0, 0, NOW(), NOW()), ('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()), -('page_not_found_view', '404.html', 0, 0, NOW(), NOW()), -('use_tax_free_amounts', 0, 1, 0, NOW(), NOW()), -('process_assets', '1', 0, 0, NOW(), NOW()); +('page_not_found_view', '404', 0, 0, NOW(), NOW()), +('passed_url_view', 'passed-url', 0, 0, NOW(), NOW()), +('use_tax_free_amounts', 0, 0, 0, NOW(), NOW()), +('process_assets', '1', 0, 0, NOW(), NOW()), +('thelia_admin_remember_me_cookie_name', 'tarmcn', 0, 0, NOW(), NOW()), +('thelia_admin_remember_me_cookie_expiration', 2592000, 0, 0, NOW(), NOW()), +('thelia_customer_remember_me_cookie_name', 'tcrmcn', 0, 0, NOW(), NOW()), +('thelia_customer_remember_me_cookie_expiration', 31536000, 0, 0, NOW(), NOW()), +('session_config.handlers', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler', 0, 0, NOW(), NOW()) +; INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES -(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()); +(1, 'TheliaDebugBar', 1, 1, 1, 'TheliaDebugBar\\TheliaDebugBar', NOW(), NOW()), +(2, 'Colissimo', 2, 0, 1, 'Colissimo\\Colissimo', NOW(), NOW()), +(3, 'Cheque', 3, 0, 1, 'Cheque\\Cheque', NOW(), NOW()), +(4, 'FakeCB', 3, 0, 2, 'FakeCB\\FakeCB', NOW(), NOW()); + +INSERT INTO `module_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES +('2', 'en_US', '72h delivery', NULL, NULL, NULL), +('2', 'fr_FR', 'Livraison par colissimo en 72h', NULL, NULL, NULL); + INSERT INTO `customer_title`(`id`, `by_default`, `position`, `created_at`, `updated_at`) VALUES (1, 1, 1, NOW(), NOW()), @@ -37,13 +55,13 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES (3, 'fr_FR', 'Mlle', 'Madamemoiselle'), (3, 'en_US', 'Miss', 'Miss'); -INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate`, `position` ,`by_default` ,`created_at` ,`updated_at`) +INSERT INTO `currency` (`id`, `code`, `symbol`, `rate`, `position`, `by_default`, `created_at`, `updated_at`) VALUES -(1, 'EUR', '€', '1', 1, '1', NOW() , NOW()), +(1, 'EUR', '€', '1', 1, '1', NOW(), NOW()), (2, 'USD', '$', '1.26', 2, '0', NOW(), NOW()), (3, 'GBP', '£', '0.89', 3, '0', NOW(), NOW()); -INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`) +INSERT INTO `currency_i18n` (`id`, `locale`, `name`) VALUES (1, 'fr_FR', 'Euro'), (1, 'en_US', 'Euro'), @@ -52,272 +70,287 @@ VALUES (3, 'fr_FR', 'Livre anglaise'), (3, 'en_US', 'UK Pound'); +INSERT INTO `area` (`id`, `name`, `postage`, `created_at`, `updated_at`) VALUES +(1, 'France', NULL, NOW(), NOW()), +(2, 'Area 1', NULL, NOW(), NOW()), +(3, 'Area 2', NULL, NOW(), NOW()), +(4, 'Area 3', NULL, NOW(), NOW()), +(5, 'Area 4', NULL, NOW(), NOW()), +(6, 'Area 5', NULL, NOW(), NOW()), +(7, 'Area 6', NULL, NOW(), NOW()), +(8, 'Area 7', NULL, NOW(), NOW()), +(9, 'Area 8', NULL, NOW(), NOW()), +(10, 'DOM', NULL, NOW(), NOW()), +(11, 'TOM', NULL, NOW(), NOW()); -INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES -(1, NULL, '4', 'AF', 'AFG', NOW(), NOW()), -(2, NULL, '710', 'ZA', 'ZAF', NOW(), NOW()), -(3, NULL, '8', 'AL', 'ALB', NOW(), NOW()), -(4, NULL, '12', 'DZ', 'DZA', NOW(), NOW()), -(5, NULL, '276', 'DE', 'DEU', NOW(), NOW()), -(6, NULL, '20', 'AD', 'AND', NOW(), NOW()), -(7, NULL, '24', 'AO', 'AGO', NOW(), NOW()), -(8, NULL, '28', 'AG', 'ATG', NOW(), NOW()), -(9, NULL, '682', 'SA', 'SAU', NOW(), NOW()), -(10, NULL, '32', 'AR', 'ARG', NOW(), NOW()), -(11, NULL, '51', 'AM', 'ARM', NOW(), NOW()), -(12, NULL, '36', 'AU', 'AUS', NOW(), NOW()), -(13, NULL, '40', 'AT', 'AUT', NOW(), NOW()), -(14, NULL, '31', 'AZ', 'AZE', NOW(), NOW()), -(15, NULL, '44', 'BS', 'BHS', NOW(), NOW()), -(16, NULL, '48', 'BR', 'BHR', NOW(), NOW()), -(17, NULL, '50', 'BD', 'BGD', NOW(), NOW()), -(18, NULL, '52', 'BB', 'BRB', NOW(), NOW()), -(19, NULL, '585', 'PW', 'PLW', NOW(), NOW()), -(20, NULL, '56', 'BE', 'BEL', NOW(), NOW()), -(21, NULL, '84', 'BL', 'BLZ', NOW(), NOW()), -(22, NULL, '204', 'BJ', 'BEN', NOW(), NOW()), -(23, NULL, '64', 'BT', 'BTN', NOW(), NOW()), -(24, NULL, '112', 'BY', 'BLR', NOW(), NOW()), -(25, NULL, '104', 'MM', 'MMR', NOW(), NOW()), -(26, NULL, '68', 'BO', 'BOL', NOW(), NOW()), -(27, NULL, '70', 'BA', 'BIH', NOW(), NOW()), -(28, NULL, '72', 'BW', 'BWA', NOW(), NOW()), -(29, NULL, '76', 'BR', 'BRA', NOW(), NOW()), -(30, NULL, '96', 'BN', 'BRN', NOW(), NOW()), -(31, NULL, '100', 'BG', 'BGR', NOW(), NOW()), -(32, NULL, '854', 'BF', 'BFA', NOW(), NOW()), -(33, NULL, '108', 'BI', 'BDI', NOW(), NOW()), -(34, NULL, '116', 'KH', 'KHM', NOW(), NOW()), -(35, NULL, '120', 'CM', 'CMR', NOW(), NOW()), -(37, NULL, '132', 'CV', 'CPV', NOW(), NOW()), -(38, NULL, '152', 'CL', 'CHL', NOW(), NOW()), -(39, NULL, '156', 'CN', 'CHN', NOW(), NOW()), -(40, NULL, '196', 'CY', 'CYP', NOW(), NOW()), -(41, NULL, '170', 'CO', 'COL', NOW(), NOW()), -(42, NULL, '174', 'KM', 'COM', NOW(), NOW()), -(43, NULL, '178', 'CG', 'COG', NOW(), NOW()), -(44, NULL, '184', 'CK', 'COK', NOW(), NOW()), -(45, NULL, '408', 'KP', 'PRK', NOW(), NOW()), -(46, NULL, '410', 'KR', 'KOR', NOW(), NOW()), -(47, NULL, '188', 'CR', 'CRI', NOW(), NOW()), -(48, NULL, '384', 'CI', 'CIV', NOW(), NOW()), -(49, NULL, '191', 'HR', 'HRV', NOW(), NOW()), -(50, NULL, '192', 'CU', 'CUB', NOW(), NOW()), -(51, NULL, '208', 'DK', 'DNK', NOW(), NOW()), -(52, NULL, '262', 'DJ', 'DJI', NOW(), NOW()), -(53, NULL, '212', 'DM', 'DMA', NOW(), NOW()), -(54, NULL, '818', 'EG', 'EGY', NOW(), NOW()), -(55, NULL, '784', 'AE', 'ARE', NOW(), NOW()), -(56, NULL, '218', 'EC', 'ECU', NOW(), NOW()), -(57, NULL, '232', 'ER', 'ERI', NOW(), NOW()), -(58, NULL, '724', 'ES', 'ESP', NOW(), NOW()), -(59, NULL, '233', 'EE', 'EST', NOW(), NOW()), -(61, NULL, '231', 'ET', 'ETH', NOW(), NOW()), -(62, NULL, '242', 'FJ', 'FJI', NOW(), NOW()), -(63, NULL, '246', 'FI', 'FIN', NOW(), NOW()), -(64, NULL, '250', 'FR', 'FRA', NOW(), NOW()), -(65, NULL, '266', 'GA', 'GAB', NOW(), NOW()), -(66, NULL, '270', 'GM', 'GMB', NOW(), NOW()), -(67, NULL, '268', 'GE', 'GEO', NOW(), NOW()), -(68, NULL, '288', 'GH', 'GHA', NOW(), NOW()), -(69, NULL, '300', 'GR', 'GRC', NOW(), NOW()), -(70, NULL, '308', 'GD', 'GRD', NOW(), NOW()), -(71, NULL, '320', 'GT', 'GTM', NOW(), NOW()), -(72, NULL, '324', 'GN', 'GIN', NOW(), NOW()), -(73, NULL, '624', 'GW', 'GNB', NOW(), NOW()), -(74, NULL, '226', 'GQ', 'GNQ', NOW(), NOW()), -(75, NULL, '328', 'GY', 'GUY', NOW(), NOW()), -(76, NULL, '332', 'HT', 'HTI', NOW(), NOW()), -(77, NULL, '340', 'HN', 'HND', NOW(), NOW()), -(78, NULL, '348', 'HU', 'HUN', NOW(), NOW()), -(79, NULL, '356', 'IN', 'IND', NOW(), NOW()), -(80, NULL, '360', 'ID', 'IDN', NOW(), NOW()), -(81, NULL, '364', 'IR', 'IRN', NOW(), NOW()), -(82, NULL, '368', 'IQ', 'IRQ', NOW(), NOW()), -(83, NULL, '372', 'IE', 'IRL', NOW(), NOW()), -(84, NULL, '352', 'IS', 'ISL', NOW(), NOW()), -(85, NULL, '376', 'IL', 'ISR', NOW(), NOW()), -(86, NULL, '380', 'IT', 'ITA', NOW(), NOW()), -(87, NULL, '388', 'JM', 'JAM', NOW(), NOW()), -(88, NULL, '392', 'JP', 'JPN', NOW(), NOW()), -(89, NULL, '400', 'JO', 'JOR', NOW(), NOW()), -(90, NULL, '398', 'KZ', 'KAZ', NOW(), NOW()), -(91, NULL, '404', 'KE', 'KEN', NOW(), NOW()), -(92, NULL, '417', 'KG', 'KGZ', NOW(), NOW()), -(93, NULL, '296', 'KI', 'KIR', NOW(), NOW()), -(94, NULL, '414', 'KW', 'KWT', NOW(), NOW()), -(95, NULL, '418', 'LA', 'LAO', NOW(), NOW()), -(96, NULL, '426', 'LS', 'LSO', NOW(), NOW()), -(97, NULL, '428', 'LV', 'LVA', NOW(), NOW()), -(98, NULL, '422', 'LB', 'LBN', NOW(), NOW()), -(99, NULL, '430', 'LR', 'LBR', NOW(), NOW()), -(100, NULL, '343', 'LY', 'LBY', NOW(), NOW()), -(101, NULL, '438', 'LI', 'LIE', NOW(), NOW()), -(102, NULL, '440', 'LT', 'LTU', NOW(), NOW()), -(103, NULL, '442', 'LU', 'LUX', NOW(), NOW()), -(104, NULL, '807', 'MK', 'MKD', NOW(), NOW()), -(105, NULL, '450', 'MD', 'MDG', NOW(), NOW()), -(106, NULL, '458', 'MY', 'MYS', NOW(), NOW()), -(107, NULL, '454', 'MW', 'MWI', NOW(), NOW()), -(108, NULL, '462', 'MV', 'MDV', NOW(), NOW()), -(109, NULL, '466', 'ML', 'MLI', NOW(), NOW()), -(110, NULL, '470', 'MT', 'MLT', NOW(), NOW()), -(111, NULL, '504', 'MA', 'MAR', NOW(), NOW()), -(112, NULL, '584', 'MH', 'MHL', NOW(), NOW()), -(113, NULL, '480', 'MU', 'MUS', NOW(), NOW()), -(114, NULL, '478', 'MR', 'MRT', NOW(), NOW()), -(115, NULL, '484', 'MX', 'MEX', NOW(), NOW()), -(116, NULL, '583', 'FM', 'FSM', NOW(), NOW()), -(117, NULL, '498', 'MD', 'MDA', NOW(), NOW()), -(118, NULL, '492', 'MC', 'MCO', NOW(), NOW()), -(119, NULL, '496', 'MN', 'MNG', NOW(), NOW()), -(120, NULL, '508', 'MZ', 'MOZ', NOW(), NOW()), -(121, NULL, '516', 'NA', 'NAM', NOW(), NOW()), -(122, NULL, '520', 'NR', 'NRU', NOW(), NOW()), -(123, NULL, '524', 'NP', 'NPL', NOW(), NOW()), -(124, NULL, '558', 'NI', 'NIC', NOW(), NOW()), -(125, NULL, '562', 'NE', 'NER', NOW(), NOW()), -(126, NULL, '566', 'NG', 'NGA', NOW(), NOW()), -(127, NULL, '570', 'NU', 'NIU', NOW(), NOW()), -(128, NULL, '578', 'NO', 'NOR', NOW(), NOW()), -(129, NULL, '554', 'NZ', 'NZL', NOW(), NOW()), -(130, NULL, '512', 'OM', 'OMN', NOW(), NOW()), -(131, NULL, '800', 'UG', 'UGA', NOW(), NOW()), -(132, NULL, '860', 'UZ', 'UZB', NOW(), NOW()), -(133, NULL, '586', 'PK', 'PAK', NOW(), NOW()), -(134, NULL, '591', 'PA', 'PAN', NOW(), NOW()), -(135, NULL, '598', 'PG', 'PNG', NOW(), NOW()), -(136, NULL, '600', 'PY', 'PRY', NOW(), NOW()), -(137, NULL, '528', 'NL', 'NLD', NOW(), NOW()), -(138, NULL, '604', 'PE', 'PER', NOW(), NOW()), -(139, NULL, '608', 'PH', 'PHL', NOW(), NOW()), -(140, NULL, '616', 'PL', 'POL', NOW(), NOW()), -(141, NULL, '620', 'PT', 'PRT', NOW(), NOW()), -(142, NULL, '634', 'QA', 'QAT', NOW(), NOW()), -(143, NULL, '140', 'CF', 'CAF', NOW(), NOW()), -(144, NULL, '214', 'DO', 'DOM', NOW(), NOW()), -(145, NULL, '203', 'CZ', 'CZE', NOW(), NOW()), -(146, NULL, '642', 'RO', 'ROU', NOW(), NOW()), -(147, NULL, '826', 'GB', 'GBR', NOW(), NOW()), -(148, NULL, '643', 'RU', 'RUS', NOW(), NOW()), -(149, NULL, '646', 'RW', 'RWA', NOW(), NOW()), -(150, NULL, '659', 'KN', 'KNA', NOW(), NOW()), -(151, NULL, '662', 'LC', 'LCA', NOW(), NOW()), -(152, NULL, '674', 'SM', 'SMR', NOW(), NOW()), -(153, NULL, '670', 'VC', 'VCT', NOW(), NOW()), -(154, NULL, '90', 'SB', 'SLB', NOW(), NOW()), -(155, NULL, '222', 'SV', 'SLV', NOW(), NOW()), -(156, NULL, '882', 'WS', 'WSM', NOW(), NOW()), -(157, NULL, '678', 'ST', 'STP', NOW(), NOW()), -(158, NULL, '686', 'SN', 'SEN', NOW(), NOW()), -(159, NULL, '690', 'SC', 'SYC', NOW(), NOW()), -(160, NULL, '694', 'SL', 'SLE', NOW(), NOW()), -(161, NULL, '702', 'SG', 'SGP', NOW(), NOW()), -(162, NULL, '703', 'SK', 'SVK', NOW(), NOW()), -(163, NULL, '705', 'SI', 'SVN', NOW(), NOW()), -(164, NULL, '706', 'SO', 'SOM', NOW(), NOW()), -(165, NULL, '729', 'SD', 'SDN', NOW(), NOW()), -(166, NULL, '144', 'LK', 'LKA', NOW(), NOW()), -(167, NULL, '752', 'SE', 'SWE', NOW(), NOW()), -(168, NULL, '756', 'CH', 'CHE', NOW(), NOW()), -(169, NULL, '740', 'SR', 'SUR', NOW(), NOW()), -(170, NULL, '748', 'SZ', 'SWZ', NOW(), NOW()), -(171, NULL, '760', 'SY', 'SYR', NOW(), NOW()), -(172, NULL, '762', 'TJ', 'TJK', NOW(), NOW()), -(173, NULL, '834', 'TZ', 'TZA', NOW(), NOW()), -(174, NULL, '148', 'TD', 'TCD', NOW(), NOW()), -(175, NULL, '764', 'TH', 'THA', NOW(), NOW()), -(176, NULL, '768', 'TG', 'TGO', NOW(), NOW()), -(177, NULL, '776', 'TO', 'TON', NOW(), NOW()), -(178, NULL, '780', 'TT', 'TTO', NOW(), NOW()), -(179, NULL, '788', 'TN', 'TUN', NOW(), NOW()), -(180, NULL, '795', 'TM', 'TKM', NOW(), NOW()), -(181, NULL, '792', 'TR', 'TUR', NOW(), NOW()), -(182, NULL, '798', 'TV', 'TUV', NOW(), NOW()), -(183, NULL, '804', 'UA', 'UKR', NOW(), NOW()), -(184, NULL, '858', 'UY', 'URY', NOW(), NOW()), -(185, NULL, '336', 'VA', 'VAT', NOW(), NOW()), -(186, NULL, '548', 'VU', 'VUT', NOW(), NOW()), -(187, NULL, '862', 'VE', 'VEN', NOW(), NOW()), -(188, NULL, '704', 'VN', 'VNM', NOW(), NOW()), -(189, NULL, '887', 'YE', 'YEM', NOW(), NOW()), -(190, NULL, '807', 'MK', 'MKD', NOW(), NOW()), -(191, NULL, '180', 'CD', 'COD', NOW(), NOW()), -(192, NULL, '894', 'ZM', 'ZMB', NOW(), NOW()), -(193, NULL, '716', 'ZW', 'ZWE', NOW(), NOW()), -(196, NULL, '840', 'US', 'USA', NOW(), NOW()), -(197, NULL, '840', 'US', 'USA', NOW(), NOW()), -(198, NULL, '840', 'US', 'USA', NOW(), NOW()), -(199, NULL, '840', 'US', 'USA', NOW(), NOW()), -(200, NULL, '840', 'US', 'USA', NOW(), NOW()), -(201, NULL, '840', 'US', 'USA', NOW(), NOW()), -(202, NULL, '840', 'US', 'USA', NOW(), NOW()), -(203, NULL, '840', 'US', 'USA', NOW(), NOW()), -(204, NULL, '840', 'US', 'USA', NOW(), NOW()), -(205, NULL, '840', 'US', 'USA', NOW(), NOW()), -(206, NULL, '840', 'US', 'USA', NOW(), NOW()), -(207, NULL, '840', 'US', 'USA', NOW(), NOW()), -(208, NULL, '840', 'US', 'USA', NOW(), NOW()), -(209, NULL, '840', 'US', 'USA', NOW(), NOW()), -(210, NULL, '840', 'US', 'USA', NOW(), NOW()), -(211, NULL, '840', 'US', 'USA', NOW(), NOW()), -(212, NULL, '840', 'US', 'USA', NOW(), NOW()), -(213, NULL, '840', 'US', 'USA', NOW(), NOW()), -(214, NULL, '840', 'US', 'USA', NOW(), NOW()), -(215, NULL, '840', 'US', 'USA', NOW(), NOW()), -(216, NULL, '840', 'US', 'USA', NOW(), NOW()), -(217, NULL, '840', 'US', 'USA', NOW(), NOW()), -(218, NULL, '840', 'US', 'USA', NOW(), NOW()), -(219, NULL, '840', 'US', 'USA', NOW(), NOW()), -(220, NULL, '840', 'US', 'USA', NOW(), NOW()), -(221, NULL, '840', 'US', 'USA', NOW(), NOW()), -(222, NULL, '840', 'US', 'USA', NOW(), NOW()), -(223, NULL, '840', 'US', 'USA', NOW(), NOW()), -(224, NULL, '840', 'US', 'USA', NOW(), NOW()), -(225, NULL, '840', 'US', 'USA', NOW(), NOW()), -(226, NULL, '840', 'US', 'USA', NOW(), NOW()), -(227, NULL, '840', 'US', 'USA', NOW(), NOW()), -(228, NULL, '840', 'US', 'USA', NOW(), NOW()), -(229, NULL, '840', 'US', 'USA', NOW(), NOW()), -(230, NULL, '840', 'US', 'USA', NOW(), NOW()), -(231, NULL, '840', 'US', 'USA', NOW(), NOW()), -(232, NULL, '840', 'US', 'USA', NOW(), NOW()), -(233, NULL, '840', 'US', 'USA', NOW(), NOW()), -(234, NULL, '840', 'US', 'USA', NOW(), NOW()), -(235, NULL, '840', 'US', 'USA', NOW(), NOW()), -(236, NULL, '840', 'US', 'USA', NOW(), NOW()), -(237, NULL, '840', 'US', 'USA', NOW(), NOW()), -(238, NULL, '840', 'US', 'USA', NOW(), NOW()), -(239, NULL, '840', 'US', 'USA', NOW(), NOW()), -(240, NULL, '840', 'US', 'USA', NOW(), NOW()), -(241, NULL, '840', 'US', 'USA', NOW(), NOW()), -(242, NULL, '840', 'US', 'USA', NOW(), NOW()), -(243, NULL, '840', 'US', 'USA', NOW(), NOW()), -(244, NULL, '840', 'US', 'USA', NOW(), NOW()), -(245, NULL, '840', 'US', 'USA', NOW(), NOW()), -(246, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(247, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(248, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(249, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(250, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(251, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(252, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(253, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(254, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(255, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(256, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(257, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(258, NULL, '124', 'CA', 'CAN', NOW(), NOW()), -(259, NULL, '312', 'GP', 'GLP', NOW(), NOW()), -(260, NULL, '254', 'GF', 'GUF', NOW(), NOW()), -(261, NULL, '474', 'MQ', 'MTQ', NOW(), NOW()), -(262, NULL, '175', 'YT', 'MYT', NOW(), NOW()), -(263, NULL, '638', 'RE', 'REU', NOW(), NOW()), -(264, NULL, '666', 'PM', 'SPM', NOW(), NOW()), -(265, NULL, '540', 'NC', 'NCL', NOW(), NOW()), -(266, NULL, '258', 'PF', 'PYF', NOW(), NOW()), -(267, NULL, '876', 'WF', 'WLF', NOW(), NOW()), -(268, NULL, '840', 'US', 'USA', NOW(), NOW()); +INSERT INTO `area_delivery_module` (`id`, `area_id`, `delivery_module_id`, `created_at`, `updated_at`) VALUES +(1, 1, 2, NOW(), NOW()); + +INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `by_default`, `created_at`, `updated_at`) VALUES +(1, NULL, '4', 'AF', 'AFG', 0, NOW(), NOW()), +(2, NULL, '710', 'ZA', 'ZAF', 0, NOW(), NOW()), +(3, NULL, '8', 'AL', 'ALB', 0, NOW(), NOW()), +(4, NULL, '12', 'DZ', 'DZA', 0, NOW(), NOW()), +(5, NULL, '276', 'DE', 'DEU', 0, NOW(), NOW()), +(6, NULL, '20', 'AD', 'AND', 0, NOW(), NOW()), +(7, NULL, '24', 'AO', 'AGO', 0, NOW(), NOW()), +(8, NULL, '28', 'AG', 'ATG', 0, NOW(), NOW()), +(9, NULL, '682', 'SA', 'SAU', 0, NOW(), NOW()), +(10, NULL, '32', 'AR', 'ARG', 0, NOW(), NOW()), +(11, NULL, '51', 'AM', 'ARM', 0, NOW(), NOW()), +(12, NULL, '36', 'AU', 'AUS', 0, NOW(), NOW()), +(13, NULL, '40', 'AT', 'AUT', 0, NOW(), NOW()), +(14, NULL, '31', 'AZ', 'AZE', 0, NOW(), NOW()), +(15, NULL, '44', 'BS', 'BHS', 0, NOW(), NOW()), +(16, NULL, '48', 'BR', 'BHR', 0, NOW(), NOW()), +(17, NULL, '50', 'BD', 'BGD', 0, NOW(), NOW()), +(18, NULL, '52', 'BB', 'BRB', 0, NOW(), NOW()), +(19, NULL, '585', 'PW', 'PLW', 0, NOW(), NOW()), +(20, NULL, '56', 'BE', 'BEL', 0, NOW(), NOW()), +(21, NULL, '84', 'BL', 'BLZ', 0, NOW(), NOW()), +(22, NULL, '204', 'BJ', 'BEN', 0, NOW(), NOW()), +(23, NULL, '64', 'BT', 'BTN', 0, NOW(), NOW()), +(24, NULL, '112', 'BY', 'BLR', 0, NOW(), NOW()), +(25, NULL, '104', 'MM', 'MMR', 0, NOW(), NOW()), +(26, NULL, '68', 'BO', 'BOL', 0, NOW(), NOW()), +(27, NULL, '70', 'BA', 'BIH', 0, NOW(), NOW()), +(28, NULL, '72', 'BW', 'BWA', 0, NOW(), NOW()), +(29, NULL, '76', 'BR', 'BRA', 0, NOW(), NOW()), +(30, NULL, '96', 'BN', 'BRN', 0, NOW(), NOW()), +(31, NULL, '100', 'BG', 'BGR', 0, NOW(), NOW()), +(32, NULL, '854', 'BF', 'BFA', 0, NOW(), NOW()), +(33, NULL, '108', 'BI', 'BDI', 0, NOW(), NOW()), +(34, NULL, '116', 'KH', 'KHM', 0, NOW(), NOW()), +(35, NULL, '120', 'CM', 'CMR', 0, NOW(), NOW()), +(37, NULL, '132', 'CV', 'CPV', 0, NOW(), NOW()), +(38, NULL, '152', 'CL', 'CHL', 0, NOW(), NOW()), +(39, NULL, '156', 'CN', 'CHN', 0, NOW(), NOW()), +(40, NULL, '196', 'CY', 'CYP', 0, NOW(), NOW()), +(41, NULL, '170', 'CO', 'COL', 0, NOW(), NOW()), +(42, NULL, '174', 'KM', 'COM', 0, NOW(), NOW()), +(43, NULL, '178', 'CG', 'COG', 0, NOW(), NOW()), +(44, NULL, '184', 'CK', 'COK', 0, NOW(), NOW()), +(45, NULL, '408', 'KP', 'PRK', 0, NOW(), NOW()), +(46, NULL, '410', 'KR', 'KOR', 0, NOW(), NOW()), +(47, NULL, '188', 'CR', 'CRI', 0, NOW(), NOW()), +(48, NULL, '384', 'CI', 'CIV', 0, NOW(), NOW()), +(49, NULL, '191', 'HR', 'HRV', 0, NOW(), NOW()), +(50, NULL, '192', 'CU', 'CUB', 0, NOW(), NOW()), +(51, NULL, '208', 'DK', 'DNK', 0, NOW(), NOW()), +(52, NULL, '262', 'DJ', 'DJI', 0, NOW(), NOW()), +(53, NULL, '212', 'DM', 'DMA', 0, NOW(), NOW()), +(54, NULL, '818', 'EG', 'EGY', 0, NOW(), NOW()), +(55, NULL, '784', 'AE', 'ARE', 0, NOW(), NOW()), +(56, NULL, '218', 'EC', 'ECU', 0, NOW(), NOW()), +(57, NULL, '232', 'ER', 'ERI', 0, NOW(), NOW()), +(58, NULL, '724', 'ES', 'ESP', 0, NOW(), NOW()), +(59, NULL, '233', 'EE', 'EST', 0, NOW(), NOW()), +(61, NULL, '231', 'ET', 'ETH', 0, NOW(), NOW()), +(62, NULL, '242', 'FJ', 'FJI', 0, NOW(), NOW()), +(63, NULL, '246', 'FI', 'FIN', 0, NOW(), NOW()), +(64, 1, '250', 'FR', 'FRA', 1, NOW(), NOW()), +(65, NULL, '266', 'GA', 'GAB', 0, NOW(), NOW()), +(66, NULL, '270', 'GM', 'GMB', 0, NOW(), NOW()), +(67, NULL, '268', 'GE', 'GEO', 0, NOW(), NOW()), +(68, NULL, '288', 'GH', 'GHA', 0, NOW(), NOW()), +(69, NULL, '300', 'GR', 'GRC', 0, NOW(), NOW()), +(70, NULL, '308', 'GD', 'GRD', 0, NOW(), NOW()), +(71, NULL, '320', 'GT', 'GTM', 0, NOW(), NOW()), +(72, NULL, '324', 'GN', 'GIN', 0, NOW(), NOW()), +(73, NULL, '624', 'GW', 'GNB', 0, NOW(), NOW()), +(74, NULL, '226', 'GQ', 'GNQ', 0, NOW(), NOW()), +(75, NULL, '328', 'GY', 'GUY', 0, NOW(), NOW()), +(76, NULL, '332', 'HT', 'HTI', 0, NOW(), NOW()), +(77, NULL, '340', 'HN', 'HND', 0, NOW(), NOW()), +(78, NULL, '348', 'HU', 'HUN', 0, NOW(), NOW()), +(79, NULL, '356', 'IN', 'IND', 0, NOW(), NOW()), +(80, NULL, '360', 'ID', 'IDN', 0, NOW(), NOW()), +(81, NULL, '364', 'IR', 'IRN', 0, NOW(), NOW()), +(82, NULL, '368', 'IQ', 'IRQ', 0, NOW(), NOW()), +(83, NULL, '372', 'IE', 'IRL', 0, NOW(), NOW()), +(84, NULL, '352', 'IS', 'ISL', 0, NOW(), NOW()), +(85, NULL, '376', 'IL', 'ISR', 0, NOW(), NOW()), +(86, NULL, '380', 'IT', 'ITA', 0, NOW(), NOW()), +(87, NULL, '388', 'JM', 'JAM', 0, NOW(), NOW()), +(88, NULL, '392', 'JP', 'JPN', 0, NOW(), NOW()), +(89, NULL, '400', 'JO', 'JOR', 0, NOW(), NOW()), +(90, NULL, '398', 'KZ', 'KAZ', 0, NOW(), NOW()), +(91, NULL, '404', 'KE', 'KEN', 0, NOW(), NOW()), +(92, NULL, '417', 'KG', 'KGZ', 0, NOW(), NOW()), +(93, NULL, '296', 'KI', 'KIR', 0, NOW(), NOW()), +(94, NULL, '414', 'KW', 'KWT', 0, NOW(), NOW()), +(95, NULL, '418', 'LA', 'LAO', 0, NOW(), NOW()), +(96, NULL, '426', 'LS', 'LSO', 0, NOW(), NOW()), +(97, NULL, '428', 'LV', 'LVA', 0, NOW(), NOW()), +(98, NULL, '422', 'LB', 'LBN', 0, NOW(), NOW()), +(99, NULL, '430', 'LR', 'LBR', 0, NOW(), NOW()), +(100, NULL, '343', 'LY', 'LBY', 0, NOW(), NOW()), +(101, NULL, '438', 'LI', 'LIE', 0, NOW(), NOW()), +(102, NULL, '440', 'LT', 'LTU', 0, NOW(), NOW()), +(103, NULL, '442', 'LU', 'LUX', 0, NOW(), NOW()), +(104, NULL, '807', 'MK', 'MKD', 0, NOW(), NOW()), +(105, NULL, '450', 'MD', 'MDG', 0, NOW(), NOW()), +(106, NULL, '458', 'MY', 'MYS', 0, NOW(), NOW()), +(107, NULL, '454', 'MW', 'MWI', 0, NOW(), NOW()), +(108, NULL, '462', 'MV', 'MDV', 0, NOW(), NOW()), +(109, NULL, '466', 'ML', 'MLI', 0, NOW(), NOW()), +(110, NULL, '470', 'MT', 'MLT', 0, NOW(), NOW()), +(111, NULL, '504', 'MA', 'MAR', 0, NOW(), NOW()), +(112, NULL, '584', 'MH', 'MHL', 0, NOW(), NOW()), +(113, NULL, '480', 'MU', 'MUS', 0, NOW(), NOW()), +(114, NULL, '478', 'MR', 'MRT', 0, NOW(), NOW()), +(115, NULL, '484', 'MX', 'MEX', 0, NOW(), NOW()), +(116, NULL, '583', 'FM', 'FSM', 0, NOW(), NOW()), +(117, NULL, '498', 'MD', 'MDA', 0, NOW(), NOW()), +(118, NULL, '492', 'MC', 'MCO', 0, NOW(), NOW()), +(119, NULL, '496', 'MN', 'MNG', 0, NOW(), NOW()), +(120, NULL, '508', 'MZ', 'MOZ', 0, NOW(), NOW()), +(121, NULL, '516', 'NA', 'NAM', 0, NOW(), NOW()), +(122, NULL, '520', 'NR', 'NRU', 0, NOW(), NOW()), +(123, NULL, '524', 'NP', 'NPL', 0, NOW(), NOW()), +(124, NULL, '558', 'NI', 'NIC', 0, NOW(), NOW()), +(125, NULL, '562', 'NE', 'NER', 0, NOW(), NOW()), +(126, NULL, '566', 'NG', 'NGA', 0, NOW(), NOW()), +(127, NULL, '570', 'NU', 'NIU', 0, NOW(), NOW()), +(128, NULL, '578', 'NO', 'NOR', 0, NOW(), NOW()), +(129, NULL, '554', 'NZ', 'NZL', 0, NOW(), NOW()), +(130, NULL, '512', 'OM', 'OMN', 0, NOW(), NOW()), +(131, NULL, '800', 'UG', 'UGA', 0, NOW(), NOW()), +(132, NULL, '860', 'UZ', 'UZB', 0, NOW(), NOW()), +(133, NULL, '586', 'PK', 'PAK', 0, NOW(), NOW()), +(134, NULL, '591', 'PA', 'PAN', 0, NOW(), NOW()), +(135, NULL, '598', 'PG', 'PNG', 0, NOW(), NOW()), +(136, NULL, '600', 'PY', 'PRY', 0, NOW(), NOW()), +(137, NULL, '528', 'NL', 'NLD', 0, NOW(), NOW()), +(138, NULL, '604', 'PE', 'PER', 0, NOW(), NOW()), +(139, NULL, '608', 'PH', 'PHL', 0, NOW(), NOW()), +(140, NULL, '616', 'PL', 'POL', 0, NOW(), NOW()), +(141, NULL, '620', 'PT', 'PRT', 0, NOW(), NOW()), +(142, NULL, '634', 'QA', 'QAT', 0, NOW(), NOW()), +(143, NULL, '140', 'CF', 'CAF', 0, NOW(), NOW()), +(144, NULL, '214', 'DO', 'DOM', 0, NOW(), NOW()), +(145, NULL, '203', 'CZ', 'CZE', 0, NOW(), NOW()), +(146, NULL, '642', 'RO', 'ROU', 0, NOW(), NOW()), +(147, NULL, '826', 'GB', 'GBR', 0, NOW(), NOW()), +(148, NULL, '643', 'RU', 'RUS', 0, NOW(), NOW()), +(149, NULL, '646', 'RW', 'RWA', 0, NOW(), NOW()), +(150, NULL, '659', 'KN', 'KNA', 0, NOW(), NOW()), +(151, NULL, '662', 'LC', 'LCA', 0, NOW(), NOW()), +(152, NULL, '674', 'SM', 'SMR', 0, NOW(), NOW()), +(153, NULL, '670', 'VC', 'VCT', 0, NOW(), NOW()), +(154, NULL, '90', 'SB', 'SLB', 0, NOW(), NOW()), +(155, NULL, '222', 'SV', 'SLV', 0, NOW(), NOW()), +(156, NULL, '882', 'WS', 'WSM', 0, NOW(), NOW()), +(157, NULL, '678', 'ST', 'STP', 0, NOW(), NOW()), +(158, NULL, '686', 'SN', 'SEN', 0, NOW(), NOW()), +(159, NULL, '690', 'SC', 'SYC', 0, NOW(), NOW()), +(160, NULL, '694', 'SL', 'SLE', 0, NOW(), NOW()), +(161, NULL, '702', 'SG', 'SGP', 0, NOW(), NOW()), +(162, NULL, '703', 'SK', 'SVK', 0, NOW(), NOW()), +(163, NULL, '705', 'SI', 'SVN', 0, NOW(), NOW()), +(164, NULL, '706', 'SO', 'SOM', 0, NOW(), NOW()), +(165, NULL, '729', 'SD', 'SDN', 0, NOW(), NOW()), +(166, NULL, '144', 'LK', 'LKA', 0, NOW(), NOW()), +(167, NULL, '752', 'SE', 'SWE', 0, NOW(), NOW()), +(168, NULL, '756', 'CH', 'CHE', 0, NOW(), NOW()), +(169, NULL, '740', 'SR', 'SUR', 0, NOW(), NOW()), +(170, NULL, '748', 'SZ', 'SWZ', 0, NOW(), NOW()), +(171, NULL, '760', 'SY', 'SYR', 0, NOW(), NOW()), +(172, NULL, '762', 'TJ', 'TJK', 0, NOW(), NOW()), +(173, NULL, '834', 'TZ', 'TZA', 0, NOW(), NOW()), +(174, NULL, '148', 'TD', 'TCD', 0, NOW(), NOW()), +(175, NULL, '764', 'TH', 'THA', 0, NOW(), NOW()), +(176, NULL, '768', 'TG', 'TGO', 0, NOW(), NOW()), +(177, NULL, '776', 'TO', 'TON', 0, NOW(), NOW()), +(178, NULL, '780', 'TT', 'TTO', 0, NOW(), NOW()), +(179, NULL, '788', 'TN', 'TUN', 0, NOW(), NOW()), +(180, NULL, '795', 'TM', 'TKM', 0, NOW(), NOW()), +(181, NULL, '792', 'TR', 'TUR', 0, NOW(), NOW()), +(182, NULL, '798', 'TV', 'TUV', 0, NOW(), NOW()), +(183, NULL, '804', 'UA', 'UKR', 0, NOW(), NOW()), +(184, NULL, '858', 'UY', 'URY', 0, NOW(), NOW()), +(185, NULL, '336', 'VA', 'VAT', 0, NOW(), NOW()), +(186, NULL, '548', 'VU', 'VUT', 0, NOW(), NOW()), +(187, NULL, '862', 'VE', 'VEN', 0, NOW(), NOW()), +(188, NULL, '704', 'VN', 'VNM', 0, NOW(), NOW()), +(189, NULL, '887', 'YE', 'YEM', 0, NOW(), NOW()), +(190, NULL, '807', 'MK', 'MKD', 0, NOW(), NOW()), +(191, NULL, '180', 'CD', 'COD', 0, NOW(), NOW()), +(192, NULL, '894', 'ZM', 'ZMB', 0, NOW(), NOW()), +(193, NULL, '716', 'ZW', 'ZWE', 0, NOW(), NOW()), +(196, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(197, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(198, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(199, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(200, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(201, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(202, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(203, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(204, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(205, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(206, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(207, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(208, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(209, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(210, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(211, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(212, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(213, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(214, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(215, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(216, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(217, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(218, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(219, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(220, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(221, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(222, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(223, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(224, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(225, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(226, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(227, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(228, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(229, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(230, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(231, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(232, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(233, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(234, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(235, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(236, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(237, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(238, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(239, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(240, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(241, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(242, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(243, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(244, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(245, NULL, '840', 'US', 'USA', 0, NOW(), NOW()), +(246, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(247, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(248, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(249, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(250, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(251, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(252, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(253, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(254, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(255, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(256, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(257, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(258, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()), +(259, NULL, '312', 'GP', 'GLP', 0, NOW(), NOW()), +(260, NULL, '254', 'GF', 'GUF', 0, NOW(), NOW()), +(261, NULL, '474', 'MQ', 'MTQ', 0, NOW(), NOW()), +(262, NULL, '175', 'YT', 'MYT', 0, NOW(), NOW()), +(263, NULL, '638', 'RE', 'REU', 0, NOW(), NOW()), +(264, NULL, '666', 'PM', 'SPM', 0, NOW(), NOW()), +(265, NULL, '540', 'NC', 'NCL', 0, NOW(), NOW()), +(266, NULL, '258', 'PF', 'PYF', 0, NOW(), NOW()), +(267, NULL, '876', 'WF', 'WLF', 0, NOW(), NOW()), +(268, NULL, '840', 'US', 'USA', 0, NOW(), NOW()); INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES (1, 'en_US', 'Afghanistan', '', '', ''), @@ -1120,17 +1153,36 @@ INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `upda INSERT INTO `tax_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'french 19.6% tax'); -INSERT INTO `tax_rule` (`id`, `created_at`, `updated_at`) +INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) VALUES - (1, NOW(), NOW()); + (1, 1, NOW(), NOW()); INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'french 19.6% tax'); INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`) VALUES (1, 64, 1, 1, NOW(), NOW()); + +INSERT INTO `order_status`(`id`, `code`, `created_at`, `updated_at`) VALUES +(1, 'not_paid', NOW(), NOW()), +(2, 'paid', NOW(), NOW()), +(3, 'processing', NOW(), NOW()), +(4, 'sent', NOW(), NOW()), +(5, 'canceled', NOW(), NOW()); + +INSERT INTO `order_status_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES +(1, 'en_US', 'Not paid', '', '', ''), +(1, 'fr_FR', 'Non payée', '', '', ''), +(2, 'en_US', 'Paid', '', '', ''), +(2, 'fr_FR', 'Payée', '', '', ''), +(3, 'en_US', 'Processing', '', '', ''), +(3, 'fr_FR', 'Traitement', '', '', ''), +(4, 'en_US', 'Sent', '', '', ''), +(4, 'fr_FR', 'Envoyée', '', '', ''), +(5, 'en_US', 'Canceled', '', '', ''), +(5, 'fr_FR', 'Annulée', '', '', ''); diff --git a/install/thelia.sql b/install/thelia.sql index dd0e9a79c..d8d8e46b3 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -36,6 +36,7 @@ CREATE TABLE `product` `ref` VARCHAR(255) NOT NULL, `visible` TINYINT DEFAULT 0 NOT NULL, `position` INTEGER NOT NULL, + `template_id` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0, @@ -44,11 +45,15 @@ CREATE TABLE `product` PRIMARY KEY (`id`), UNIQUE INDEX `ref_UNIQUE` (`ref`), INDEX `idx_product_tax_rule_id` (`tax_rule_id`), + INDEX `fk_product_template_id` (`template_id`), CONSTRAINT `fk_product_tax_rule_id` FOREIGN KEY (`tax_rule_id`) REFERENCES `tax_rule` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL + ON DELETE SET NULL, + CONSTRAINT `fk_product_template1` + FOREIGN KEY (`template_id`) + REFERENCES `template` (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -61,11 +66,13 @@ CREATE TABLE `product_category` ( `product_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, + `default_category` TINYINT(1), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`product_id`,`category_id`), INDEX `idx_product_has_category_category1` (`category_id`), INDEX `idx_product_has_category_product1` (`product_id`), + INDEX `idx_product_has_category_default` (`default_category`), CONSTRAINT `fk_product_has_category_product1` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) @@ -91,6 +98,7 @@ CREATE TABLE `country` `isocode` VARCHAR(4) NOT NULL, `isoalpha2` VARCHAR(2), `isoalpha3` VARCHAR(4), + `by_default` TINYINT, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -127,6 +135,7 @@ DROP TABLE IF EXISTS `tax_rule`; CREATE TABLE `tax_rule` ( `id` INTEGER NOT NULL AUTO_INCREMENT, + `is_default` TINYINT(1) DEFAULT 0 NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) @@ -243,31 +252,29 @@ CREATE TABLE `feature_product` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- feature_category +-- feature_template -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `feature_category`; +DROP TABLE IF EXISTS `feature_template`; -CREATE TABLE `feature_category` +CREATE TABLE `feature_template` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `feature_id` INTEGER NOT NULL, - `category_id` INTEGER NOT NULL, + `template_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_feature_category_category_id` (`category_id`), - INDEX `idx_feature_category_feature_id` (`feature_id`), - CONSTRAINT `fk_feature_category_category_id` - FOREIGN KEY (`category_id`) - REFERENCES `category` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_feature_category_feature_id` + INDEX `idx_feature_template_id` (`feature_id`), + INDEX `fk_feature_template_idx` (`template_id`), + CONSTRAINT `fk_feature_template_id` FOREIGN KEY (`feature_id`) REFERENCES `feature` (`id`) ON UPDATE RESTRICT - ON DELETE CASCADE + ON DELETE CASCADE, + CONSTRAINT `fk_feature_template` + FOREIGN KEY (`template_id`) + REFERENCES `template` (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -337,6 +344,8 @@ CREATE TABLE `attribute_combination` CONSTRAINT `fk_attribute_combination_product_sale_elements_id` FOREIGN KEY (`product_sale_elements_id`) REFERENCES `product_sale_elements` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -367,31 +376,29 @@ CREATE TABLE `product_sale_elements` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- attribute_category +-- attribute_template -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `attribute_category`; +DROP TABLE IF EXISTS `attribute_template`; -CREATE TABLE `attribute_category` +CREATE TABLE `attribute_template` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `category_id` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL, + `template_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_attribute_category_category_id` (`category_id`), - INDEX `idx_attribute_category_attribute_id` (`attribute_id`), - CONSTRAINT `fk_attribute_category_category_id` - FOREIGN KEY (`category_id`) - REFERENCES `category` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_attribute_category_attribute_id` + INDEX `idx_attribute_template_id` (`attribute_id`), + INDEX `fk_attribute_template_idx` (`template_id`), + CONSTRAINT `fk_attribute_template_id` FOREIGN KEY (`attribute_id`) REFERENCES `attribute` (`id`) ON UPDATE RESTRICT - ON DELETE CASCADE + ON DELETE CASCADE, + CONSTRAINT `fk_attribute_template` + FOREIGN KEY (`template_id`) + REFERENCES `template` (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -433,6 +440,8 @@ CREATE TABLE `customer` `lang` VARCHAR(10), `sponsor` VARCHAR(50), `discount` FLOAT, + `remember_me_token` VARCHAR(255), + `remember_me_serial` VARCHAR(255), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -628,54 +637,73 @@ DROP TABLE IF EXISTS `order`; CREATE TABLE `order` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `ref` VARCHAR(45), + `ref` VARCHAR(45) NOT NULL, `customer_id` INTEGER NOT NULL, - `address_invoice` INTEGER, - `address_delivery` INTEGER, + `invoice_order_address_id` INTEGER NOT NULL, + `delivery_order_address_id` INTEGER NOT NULL, `invoice_date` DATE, - `currency_id` INTEGER, + `currency_id` INTEGER NOT NULL, `currency_rate` FLOAT NOT NULL, - `transaction` VARCHAR(100), - `delivery_num` VARCHAR(100), - `invoice` VARCHAR(100), - `postage` FLOAT, - `payment` VARCHAR(45) NOT NULL, - `carrier` VARCHAR(45) NOT NULL, - `status_id` INTEGER, - `lang` VARCHAR(10) NOT NULL, + `transaction_ref` VARCHAR(100) COMMENT 'transaction reference - usually use to identify a transaction with banking modules', + `delivery_ref` VARCHAR(100) COMMENT 'delivery reference - usually use to identify a delivery progress on a distant delivery tracker website', + `invoice_ref` VARCHAR(100) COMMENT 'the invoice reference', + `postage` FLOAT NOT NULL, + `payment_module_id` INTEGER NOT NULL, + `delivery_module_id` INTEGER NOT NULL, + `status_id` INTEGER NOT NULL, + `lang_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), + UNIQUE INDEX `ref_UNIQUE` (`ref`), INDEX `idx_order_currency_id` (`currency_id`), INDEX `idx_order_customer_id` (`customer_id`), - INDEX `idx_order_address_invoice` (`address_invoice`), - INDEX `idx_order_address_delivery` (`address_delivery`), + INDEX `idx_order_invoice_order_address_id` (`invoice_order_address_id`), + INDEX `idx_order_delivery_order_address_id` (`delivery_order_address_id`), INDEX `idx_order_status_id` (`status_id`), + INDEX `fk_order_payment_module_id_idx` (`payment_module_id`), + INDEX `fk_order_delivery_module_id_idx` (`delivery_module_id`), + INDEX `fk_order_lang_id_idx` (`lang_id`), CONSTRAINT `fk_order_currency_id` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL, + ON DELETE RESTRICT, CONSTRAINT `fk_order_customer_id` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_order_address_invoice` - FOREIGN KEY (`address_invoice`) + ON DELETE RESTRICT, + CONSTRAINT `fk_order_invoice_order_address_id` + FOREIGN KEY (`invoice_order_address_id`) REFERENCES `order_address` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL, - CONSTRAINT `fk_order_address_delivery` - FOREIGN KEY (`address_delivery`) + ON DELETE RESTRICT, + CONSTRAINT `fk_order_delivery_order_address_id` + FOREIGN KEY (`delivery_order_address_id`) REFERENCES `order_address` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL, + ON DELETE RESTRICT, CONSTRAINT `fk_order_status_id` FOREIGN KEY (`status_id`) REFERENCES `order_status` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL + ON DELETE RESTRICT, + CONSTRAINT `fk_order_payment_module_id` + FOREIGN KEY (`payment_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE RESTRICT, + CONSTRAINT `fk_order_delivery_module_id` + FOREIGN KEY (`delivery_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE RESTRICT, + CONSTRAINT `fk_order_lang_id` + FOREIGN KEY (`lang_id`) + REFERENCES `lang` (`id`) + ON UPDATE RESTRICT + ON DELETE RESTRICT ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -732,14 +760,21 @@ CREATE TABLE `order_product` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `order_id` INTEGER NOT NULL, - `product_ref` VARCHAR(255), + `product_ref` VARCHAR(255) NOT NULL, + `product_sale_elements_ref` VARCHAR(255) NOT NULL, `title` VARCHAR(255), - `description` TEXT, `chapo` TEXT, + `description` LONGTEXT, + `postscriptum` TEXT, `quantity` FLOAT NOT NULL, `price` FLOAT NOT NULL, - `tax` FLOAT, - `parent` INTEGER, + `promo_price` VARCHAR(45), + `was_new` TINYINT NOT NULL, + `was_in_promo` TINYINT NOT NULL, + `weight` VARCHAR(45), + `tax_rule_title` VARCHAR(255), + `tax_rule_description` LONGTEXT, + `parent` INTEGER COMMENT 'not managed yet', `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -760,29 +795,36 @@ DROP TABLE IF EXISTS `order_status`; CREATE TABLE `order_status` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `code` VARCHAR(45), - `created_at` DATETIME, - `updated_at` DATETIME, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --------------------------------------------------------------------- --- order_feature --- --------------------------------------------------------------------- - -DROP TABLE IF EXISTS `order_feature`; - -CREATE TABLE `order_feature` -( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `order_product_id` INTEGER NOT NULL, - `feature_desc` VARCHAR(255), - `feature_av_desc` VARCHAR(255), + `code` VARCHAR(45) NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_order_feature_order_product_id` (`order_product_id`), - CONSTRAINT `fk_order_feature_order_product_id` + UNIQUE INDEX `code_UNIQUE` (`code`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- order_product_attribute_combination +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `order_product_attribute_combination`; + +CREATE TABLE `order_product_attribute_combination` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `order_product_id` INTEGER NOT NULL, + `attribute_title` VARCHAR(255) NOT NULL, + `attribute_chapo` TEXT, + `attribute_description` LONGTEXT, + `attribute_postscriptumn` TEXT, + `attribute_av_title` VARCHAR(255) NOT NULL, + `attribute_av_chapo` TEXT, + `attribute_av_description` LONGTEXT, + `attribute_av_postscriptum` TEXT, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_order_product_attribute_combination_order_product_id` (`order_product_id`), + CONSTRAINT `fk_order_product_attribute_combination_order_product_id` FOREIGN KEY (`order_product_id`) REFERENCES `order_product` (`id`) ON UPDATE RESTRICT @@ -848,32 +890,39 @@ CREATE TABLE `area` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, - `unit` FLOAT, + `postage` FLOAT, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- delivzone +-- area_delivery_module -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `delivzone`; +DROP TABLE IF EXISTS `area_delivery_module`; -CREATE TABLE `delivzone` +CREATE TABLE `area_delivery_module` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `area_id` INTEGER, - `delivery` VARCHAR(45) NOT NULL, + `area_id` INTEGER NOT NULL, + `delivery_module_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_delivzone_area_id` (`area_id`), - CONSTRAINT `fk_delivzone_area_id` + UNIQUE INDEX `area_id_delivery_module_id_UNIQUE` (`area_id`, `delivery_module_id`), + INDEX `idx_area_delivery_module_area_id` (`area_id`), + INDEX `idx_area_delivery_module_delivery_module_id_idx` (`delivery_module_id`), + CONSTRAINT `fk_area_delivery_module_area_id` FOREIGN KEY (`area_id`) REFERENCES `area` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL + ON DELETE CASCADE, + CONSTRAINT `idx_area_delivery_module_delivery_module_id` + FOREIGN KEY (`delivery_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -923,6 +972,8 @@ CREATE TABLE `admin` `password` VARCHAR(128) NOT NULL, `algo` VARCHAR(128), `salt` VARCHAR(128), + `remember_me_token` VARCHAR(255), + `remember_me_serial` VARCHAR(255), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) @@ -1122,11 +1173,13 @@ CREATE TABLE `content_folder` ( `content_id` INTEGER NOT NULL, `folder_id` INTEGER NOT NULL, + `default_folder` TINYINT(1), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`content_id`,`folder_id`), INDEX `idx_content_folder_content_id` (`content_id`), INDEX `idx_content_folder_folder_id` (`folder_id`), + INDEX `idx_content_folder_default` (`default_folder`), CONSTRAINT `fk_content_folder_content_id` FOREIGN KEY (`content_id`) REFERENCES `content` (`id`) @@ -1193,6 +1246,7 @@ CREATE TABLE `cart_item` `promo_price` FLOAT, `price_end_of_life` DATETIME, `discount` FLOAT DEFAULT 0, + `promo` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -1482,6 +1536,67 @@ CREATE TABLE `rewriting_argument` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- template +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `template`; + +CREATE TABLE `template` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- module_image +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `module_image`; + +CREATE TABLE `module_image` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `module_id` INTEGER NOT NULL, + `file` VARCHAR(255) NOT NULL, + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_module_image_module_id` (`module_id`), + CONSTRAINT `fk_module_image_module_id` + FOREIGN KEY (`module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- order_product_tax +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `order_product_tax`; + +CREATE TABLE `order_product_tax` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `order_product_id` INTEGER NOT NULL, + `title` VARCHAR(255) NOT NULL, + `description` LONGTEXT, + `amount` FLOAT NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_ order_product_tax_order_product_id` (`order_product_id`), + CONSTRAINT `fk_ order_product_tax_order_product_id0` + FOREIGN KEY (`order_product_id`) + REFERENCES `order_product` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- category_i18n -- --------------------------------------------------------------------- @@ -1556,7 +1671,7 @@ CREATE TABLE `tax_i18n` `id` INTEGER NOT NULL, `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, `title` VARCHAR(255), - `description` TEXT, + `description` LONGTEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `tax_i18n_FK_1` FOREIGN KEY (`id`) @@ -1575,7 +1690,7 @@ CREATE TABLE `tax_rule_i18n` `id` INTEGER NOT NULL, `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, `title` VARCHAR(255), - `description` TEXT, + `description` LONGTEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `tax_rule_i18n_FK_1` FOREIGN KEY (`id`) @@ -2060,6 +2175,45 @@ CREATE TABLE `folder_document_i18n` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- template_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `template_i18n`; + +CREATE TABLE `template_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `name` VARCHAR(255), + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `template_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `template` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- module_image_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `module_image_i18n`; + +CREATE TABLE `module_image_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` LONGTEXT, + `chapo` TEXT, + `postscriptum` TEXT, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `module_image_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `module_image` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- category_version -- --------------------------------------------------------------------- @@ -2097,6 +2251,7 @@ CREATE TABLE `product_version` `ref` VARCHAR(255) NOT NULL, `visible` TINYINT DEFAULT 0 NOT NULL, `position` INTEGER NOT NULL, + `template_id` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0 NOT NULL, diff --git a/local/config/schema.xml b/local/config/schema.xml index 1d928bc7b..429a52e3f 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -28,15 +28,22 @@ + + + + + + + @@ -49,6 +56,7 @@ + @@ -61,6 +69,9 @@ + + +
@@ -73,6 +84,7 @@ + @@ -89,7 +101,7 @@ - + @@ -98,7 +110,8 @@
- + + @@ -188,22 +201,22 @@
- +
- - - - - + + - - - - + + + + + + +
@@ -247,7 +260,7 @@ - + @@ -280,22 +293,22 @@
- +
- - - - - + + - - - - + + + + + + +
@@ -329,6 +342,8 @@ + + @@ -481,51 +496,72 @@
- + - - + + - + - - - - - - - - - + + + + + + + + + - + - - + + - - + + - + + + + + + + + + + - - + + - - + + + + + + + + + + + + + +
@@ -559,14 +595,21 @@
- + + - + + - - + + + + + + + @@ -577,25 +620,34 @@
- + + + +
- +
- - - + + + + + + + + + - + @@ -641,19 +693,29 @@
- +
- +
- - - + + + - + + + + + + + + + + +
@@ -694,6 +756,8 @@ + +
@@ -849,6 +913,7 @@
+ @@ -861,6 +926,9 @@ + + +
@@ -910,6 +978,7 @@ + @@ -1140,4 +1209,46 @@
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php new file mode 100755 index 000000000..4516c84f3 --- /dev/null +++ b/local/modules/Cheque/Cheque.php @@ -0,0 +1,95 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Cheque; + +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Request; +use Thelia\Model\ModuleImageQuery; +use Thelia\Module\BaseModule; +use Thelia\Module\PaymentModuleInterface; + +class Cheque extends BaseModule implements PaymentModuleInterface +{ + protected $request; + protected $dispatcher; + + public function setRequest(Request $request) + { + $this->request = $request; + } + + public function getRequest() + { + return $this->request; + } + + public function setDispatcher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + public function getDispatcher() + { + return $this->dispatcher; + } + + public function pay() + { + // no special process, waiting for the cheque. + } + + public function install() + { + + } + + public function afterActivation() + { + /* insert the images from image folder if first module activation */ + $module = $this->getModuleModel(); + if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { + $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); + } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Cheque", + "fr_FR" => "Cheque", + ) + ); + } + + public function destroy() + { + // TODO: Implement destroy() method. + } + + public function getCode() + { + return 'Cheque'; + } + +} diff --git a/local/modules/Cheque/Config/config.xml b/local/modules/Cheque/Config/config.xml new file mode 100755 index 000000000..2430f5027 --- /dev/null +++ b/local/modules/Cheque/Config/config.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/local/modules/DebugBar/Config/plugin.xml b/local/modules/Cheque/Config/plugin.xml old mode 100644 new mode 100755 similarity index 100% rename from local/modules/DebugBar/Config/plugin.xml rename to local/modules/Cheque/Config/plugin.xml diff --git a/local/modules/Cheque/images/cheque.png b/local/modules/Cheque/images/cheque.png new file mode 100644 index 000000000..16d83ba11 Binary files /dev/null and b/local/modules/Cheque/images/cheque.png differ diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php old mode 100644 new mode 100755 index 4d24cc059..7ff972feb --- a/local/modules/Colissimo/Colissimo.php +++ b/local/modules/Colissimo/Colissimo.php @@ -25,6 +25,7 @@ namespace Colissimo; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; +use Thelia\Model\Country; use Thelia\Module\BaseModule; use Thelia\Module\DeliveryModuleInterface; @@ -57,15 +58,20 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface * * calculate and return delivery price * - * @param null $country + * @param Country $country * @return mixed */ - public function calculate($country = null) + public function getPostage(Country $country) { - // TODO: Implement calculate() method. + // TODO: Implement getPostage() method. return 2; } + public function afterActivation() + { + + } + /** * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class * Like install and destroy @@ -80,4 +86,9 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface // TODO: Implement destroy() method. } + public function getCode() + { + return 'Colissimo'; + } + } diff --git a/local/modules/Colissimo/Config/config.xml b/local/modules/Colissimo/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/plugin.xml b/local/modules/Colissimo/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/schema.xml b/local/modules/Colissimo/Config/schema.xml deleted file mode 100644 index a4e2315b0..000000000 --- a/local/modules/Colissimo/Config/schema.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/local/modules/DebugBar/Config/schema.xml b/local/modules/DebugBar/Config/schema.xml deleted file mode 100644 index 86ccca913..000000000 --- a/local/modules/DebugBar/Config/schema.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/local/modules/FakeCB/Config/config.xml b/local/modules/FakeCB/Config/config.xml new file mode 100755 index 000000000..2430f5027 --- /dev/null +++ b/local/modules/FakeCB/Config/config.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/local/modules/FakeCB/Config/plugin.xml b/local/modules/FakeCB/Config/plugin.xml new file mode 100755 index 000000000..e69de29bb diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php new file mode 100755 index 000000000..ca682fab3 --- /dev/null +++ b/local/modules/FakeCB/FakeCB.php @@ -0,0 +1,95 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace FakeCB; + +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Request; +use Thelia\Model\Base\ModuleImageQuery; +use Thelia\Module\BaseModule; +use Thelia\Module\PaymentModuleInterface; + +class FakeCB extends BaseModule implements PaymentModuleInterface +{ + protected $request; + protected $dispatcher; + + public function setRequest(Request $request) + { + $this->request = $request; + } + + public function getRequest() + { + return $this->request; + } + + public function setDispatcher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + public function getDispatcher() + { + return $this->dispatcher; + } + + public function pay() + { + // TODO: Implement pay() method. + } + + public function install() + { + + } + + public function afterActivation() + { + /* insert the images from image folder if first module activation */ + $module = $this->getModuleModel(); + if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { + $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); + } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Credit Card", + "fr_FR" => "Carte de crédit", + ) + ); + } + + public function destroy() + { + // TODO: Implement destroy() method. + } + + public function getCode() + { + return 'FakeCB'; + } + +} diff --git a/local/modules/FakeCB/Tests/FakeCBTest.php b/local/modules/FakeCB/Tests/FakeCBTest.php new file mode 100755 index 000000000..20a68fc1d --- /dev/null +++ b/local/modules/FakeCB/Tests/FakeCBTest.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace FakeCB\Tests; + +use FakeCB\FakeCB; +use Thelia\Tests\Module\BaseModuleTestor; + +/** + * + * @author Etienne Roudeix + * + */ +class FakeCBTest extends BaseModuleTestor +{ + public function getTestedClassName() + { + return 'FakeCB\FakeCB'; + } + + public function getTestedInstance() + { + return new FakeCB(); + } + + public function testInstall() + { + //$fakeCB = new FakeCB(); + + //$fakeCB->install(); + } +} diff --git a/local/modules/FakeCB/images/mastercard.png b/local/modules/FakeCB/images/mastercard.png new file mode 100644 index 000000000..28701c3dd Binary files /dev/null and b/local/modules/FakeCB/images/mastercard.png differ diff --git a/local/modules/FakeCB/images/visa.png b/local/modules/FakeCB/images/visa.png new file mode 100644 index 000000000..ef0447105 Binary files /dev/null and b/local/modules/FakeCB/images/visa.png differ diff --git a/local/modules/DebugBar/Config/config.xml b/local/modules/TheliaDebugBar/Config/config.xml old mode 100644 new mode 100755 similarity index 87% rename from local/modules/DebugBar/Config/config.xml rename to local/modules/TheliaDebugBar/Config/config.xml index 12c5ccd24..564c17e66 --- a/local/modules/DebugBar/Config/config.xml +++ b/local/modules/TheliaDebugBar/Config/config.xml @@ -32,13 +32,13 @@ - + %kernel.debug% - + diff --git a/local/modules/TheliaDebugBar/Config/plugin.xml b/local/modules/TheliaDebugBar/Config/plugin.xml new file mode 100755 index 000000000..e69de29bb diff --git a/local/modules/TheliaDebugBar/Config/schema.xml b/local/modules/TheliaDebugBar/Config/schema.xml new file mode 100755 index 000000000..9056a554b --- /dev/null +++ b/local/modules/TheliaDebugBar/Config/schema.xml @@ -0,0 +1,6 @@ + + + + diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/TheliaDebugBar/DataCollector/PropelCollector.php old mode 100644 new mode 100755 similarity index 89% rename from local/modules/DebugBar/DataCollector/PropelCollector.php rename to local/modules/TheliaDebugBar/DataCollector/PropelCollector.php index b0d503b18..2605e07dd --- a/local/modules/DebugBar/DataCollector/PropelCollector.php +++ b/local/modules/TheliaDebugBar/DataCollector/PropelCollector.php @@ -21,14 +21,17 @@ /* */ /*************************************************************************************/ -namespace DebugBar\DataCollector; +namespace TheliaDebugBar\DataCollector; + +use DebugBar\DataCollector\DataCollector; +use DebugBar\DataCollector\Renderable; use Propel\Runtime\Propel; use Psr\Log\LoggerInterface; /** * Class PropelCollector - * @package DebugBar\DataCollector + * @package TheliaDebugBar\DataCollector * @author Manuel Raynaud */ class PropelCollector extends DataCollector implements Renderable, LoggerInterface @@ -40,7 +43,9 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa protected $peakMemory = 0; - public function __construct() + protected $alternativeLogger; + + public function __construct(LoggerInterface $alternativeLogger = null) { $serviceContainer = Propel::getServiceContainer(); $serviceContainer->setLogger('defaultLogger', $this); @@ -54,6 +59,8 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa 'commit', 'rollBack', )); + + $this->alternativeLogger = $alternativeLogger; } /** @@ -118,6 +125,10 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa list($sql, $duration_str) = $this->parseAndLogSqlQuery($message); $message = "$sql ($duration_str)"; + + if ($this->alternativeLogger) { + $this->alternativeLogger->log($level, $message); + } } /** @@ -172,7 +183,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function emergency($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::EMERGENCY, $message, $context); } /** @@ -187,7 +198,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function alert($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::ALERT, $message, $context); } /** @@ -201,7 +212,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function critical($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::CRITICAL, $message, $context); } /** @@ -214,7 +225,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function error($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::ERROR, $message, $context); } /** @@ -229,7 +240,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function warning($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::WARNING, $message, $context); } /** @@ -241,7 +252,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function notice($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::NOTICE, $message, $context); } /** @@ -255,7 +266,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function info($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::INFO, $message, $context); } /** @@ -267,7 +278,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function debug($message, array $context = array()) { - $this->log(null, $message, $context); + $this->log(\Thelia\Log\Tlog::DEBUG, $message, $context); } diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php old mode 100644 new mode 100755 similarity index 94% rename from local/modules/DebugBar/Listeners/DebugBarListeners.php rename to local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php index f789a9a13..c7b9d015c --- a/local/modules/DebugBar/Listeners/DebugBarListeners.php +++ b/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php @@ -21,11 +21,12 @@ /* */ /*************************************************************************************/ -namespace DebugBar\Listeners; +namespace TheliaDebugBar\Listeners; + use DebugBar\DataCollector\MemoryCollector; use DebugBar\DataCollector\MessagesCollector; use DebugBar\DataCollector\PhpInfoCollector; -use DebugBar\DataCollector\PropelCollector; +use TheliaDebugBar\DataCollector\PropelCollector; use DebugBar\DataCollector\TimeDataCollector; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -35,7 +36,7 @@ use Thelia\Core\Event\TheliaEvents; /** * Class DebugBarListeners - * @package DebugBar\Listeners + * @package TheliaDebugBar\Listeners * @author Manuel Raynaud */ class DebugBarListeners extends BaseAction implements EventSubscriberInterface { @@ -50,7 +51,7 @@ class DebugBarListeners extends BaseAction implements EventSubscriberInterface { //$debugBar->addCollector(new RequestDataCollector()); $debugBar->addCollector(new TimeDataCollector()); $debugBar->addCollector(new MemoryCollector()); - $debugBar->addCollector(new PropelCollector()); + $debugBar->addCollector(new PropelCollector(\Thelia\Log\Tlog::getInstance())); } /** diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/TheliaDebugBar/Smarty/Plugin/DebugBar.php old mode 100644 new mode 100755 similarity index 91% rename from local/modules/DebugBar/Smarty/Plugin/DebugBar.php rename to local/modules/TheliaDebugBar/Smarty/Plugin/DebugBar.php index 0cd1abee9..e03b7797c --- a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php +++ b/local/modules/TheliaDebugBar/Smarty/Plugin/DebugBar.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace DebugBar\Smarty\Plugin; +namespace TheliaDebugBar\Smarty\Plugin; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\an; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; @@ -71,7 +71,11 @@ class DebugBar extends AbstractSmartyPlugin } } - file_put_contents($cssFile, $assetCss->dump()); + if(!file_exists(THELIA_WEB_DIR . "/cache")) { + @mkdir(THELIA_WEB_DIR . "/cache"); + } + + @file_put_contents($cssFile, $assetCss->dump()); } $render = sprintf('', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE)); } @@ -96,7 +100,11 @@ class DebugBar extends AbstractSmartyPlugin } } - file_put_contents($cacheFile, $assetJs->dump()); + if(!file_exists(THELIA_WEB_DIR . "/cache")) { + @mkdir(THELIA_WEB_DIR . "/cache"); + } + + @file_put_contents($cacheFile, $assetJs->dump()); } $render = sprintf('', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE)); diff --git a/local/modules/DebugBar/DebugBar.php b/local/modules/TheliaDebugBar/TheliaDebugBar.php old mode 100644 new mode 100755 similarity index 91% rename from local/modules/DebugBar/DebugBar.php rename to local/modules/TheliaDebugBar/TheliaDebugBar.php index 7dde5fa8d..da9fddf12 --- a/local/modules/DebugBar/DebugBar.php +++ b/local/modules/TheliaDebugBar/TheliaDebugBar.php @@ -21,17 +21,22 @@ /* */ /*************************************************************************************/ -namespace DebugBar; +namespace TheliaDebugBar; use Thelia\Module\BaseModule; -class DebugBar extends BaseModule +class TheliaDebugBar extends BaseModule { /** * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class * Like install and destroy */ + public function afterActivation() + { + + } + public function install() { // TODO: Implement install() method. @@ -41,4 +46,9 @@ class DebugBar extends BaseModule { // TODO: Implement destroy() method. } + + public function getCode() + { + return 'TheliaDebugBar'; + } } diff --git a/phpunit.xml b/phpunit.xml index 1cad09b60..a45fc5bb3 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,6 +12,7 @@ core/lib/Thelia/Tests + local/modules/*/Tests diff --git a/reset_install.sh b/reset_install.sh index 399156b67..8280173d9 100755 --- a/reset_install.sh +++ b/reset_install.sh @@ -2,34 +2,43 @@ # @author Guillaume MOREL # v0.2 -echo -e "\033[47m\033[1;31m\n[WARN] This script will reset this Thelia2 install\n\033[0m" +echo -e "\033[47m\033[1;31m\n[WARNING] This script will reset this Thelia2 install\nPress ENTER to continue or ^C to cancel\033[0m" -echo -e "\n\e[01;34m[INFO] Clearing caches\e[00m\n" +read test + +echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n" php Thelia cache:clear -echo -e "\n\e[01;34m[INFO] Downloading vendors\e[00m\n" -composer install --prefer-dist +echo -e "\n\033[01;34m[INFO] Downloading vendors\033[00m\n" +composer install --prefer-dist --optimize-autoloader cd local/config/ -echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n" +echo -e "\n\033[01;34m[INFO] Building Models file\033[00m\n" ../../bin/propel build -v --output-dir=../../core/lib/ -echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n" +echo -e "\n\033[01;34m[INFO] Building SQL CREATE file\033[00m\n" ../../bin/propel sql:build -v --output-dir=../../install/ -echo -e "\n\e[01;34m[INFO] Reloaded Thelia2 database\e[00m\n" +echo -e "\n\033[01;34m[INFO] Reloading Thelia2 database\033[00m\n" cd ../.. rm install/sqldb.map php Thelia thelia:dev:reloadDB -echo -e "\n\e[01;34m[INFO] Installing fixtures\e[00m\n" +echo -e "\n\033[01;34m[INFO] Installing fixtures\033[00m\n" php install/faker.php -echo -e "\n\e[01;34m[INFO] Adding admin\e[00m\n" +echo -e "\n\033[01;34m[INFO] Adding admin\033[00m\n" php Thelia thelia:create-admin --login_name thelia2 --password thelia2 --last_name thelia2 --first_name thelia2 -echo -e "\n\e[01;34m[INFO] Clearing caches\e[00m\n" +echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n" php Thelia cache:clear -echo -e "\n\e[00;32m[SUCCESS] Reset done\e[00m\n" \ No newline at end of file +echo -e "\n\033[01;34m[INFO] Activating Delivery Module(s)\033[00m\n" +php Thelia module:activate Colissimo + +echo -e "\n\033[01;34m[INFO] Activating Payment Module(s)\033[00m\n" +php Thelia module:activate Cheque +php Thelia module:activate FakeCB + +echo -e "\n\033[00;32m[SUCCESS] Reset done\033[00m\n" \ No newline at end of file diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index b15c624f3..553466def 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -51,27 +51,27 @@
-
-
{intl l='Version %ver' ver="{$THELIA_VERSION}"}
+
+
{intl l='Version %ver' ver="{$THELIA_VERSION}"}
+ + +
{module_include location='inside_topbar'} - -
- -
- {intl l="View shop"} - - - -
- -
+
@@ -86,96 +86,98 @@
@@ -206,7 +208,6 @@ - {intl l='Édité par OpenStudio'} - {intl l='Forum Thelia'} - {intl l='Contributions Thelia'} - {intl l='interface par Steaw-Webdesign'}

{module_include location='in_footer'} diff --git a/templates/admin/default/ajax/template-attribute-list.html b/templates/admin/default/ajax/template-attribute-list.html new file mode 100644 index 000000000..a630aaa61 --- /dev/null +++ b/templates/admin/default/ajax/template-attribute-list.html @@ -0,0 +1,103 @@ +
+ {ifloop rel="free_attributes"} +
+ + + +
+ + + + +
+ + {intl l='Select an attribute and click (+) to add it to this template'} +
+ + {/ifloop} + {elseloop rel="free_attributes"} +
There is currently no available attributes.
+ {/elseloop} +
+ +
+ + + + + + + + {module_include location='template_attributes_table_header'} + + + + + + + {loop name="assigned_attributes" type="attribute" template="$template_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='template_attributes_table_row'} + + + + {/loop} + + {elseloop rel="assigned_attributes"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Attribute title'}{intl l="Actions"}
{$ID} + {$TITLE} + +
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.template.attribute.delete"} + + + + {/loop} +
+
+
+ {intl l="This template contains no attributes"} +
+
+
+{* Delete value confirmation dialog *} + +{capture "delete_attribute_dialog"} + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_attribute_dialog" + dialog_title = {intl l="Remove attribute"} + dialog_message = {intl l="Do you really want to remove this attribute from the template ?"} + + form_action = {url path='/admin/configuration/templates/attributes/delete'} + form_content = {$smarty.capture.delete_attribute_dialog nofilter} +} + + diff --git a/templates/admin/default/ajax/template-feature-list.html b/templates/admin/default/ajax/template-feature-list.html new file mode 100644 index 000000000..58bb4cf8b --- /dev/null +++ b/templates/admin/default/ajax/template-feature-list.html @@ -0,0 +1,104 @@ +
+ {ifloop rel="free_features"} +
+ + + +
+ + + + +
+ + {intl l='Select an feature and click (+) to add it to this template'} +
+ + {/ifloop} + {elseloop rel="free_features"} +
There is currently no available features.
+ {/elseloop} +
+ +
+ + + + + + + + {module_include location='template_features_table_header'} + + + + + + + {loop name="assigned_features" type="feature" template="$template_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='template_features_table_row'} + + + + {/loop} + + {elseloop rel="assigned_features"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Feature title'}{intl l="Actions"}
{$ID} + {$TITLE} + +
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.template.feature.delete"} + + + + {/loop} +
+
+
+ {intl l="This template contains no features"} +
+
+
+ +{* Delete value confirmation dialog *} + +{capture "delete_feature_dialog"} + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_feature_dialog" + dialog_title = {intl l="Remove feature"} + dialog_message = {intl l="Do you really want to remove this feature from the template ?"} + + form_action = {url path='/admin/configuration/templates/features/delete'} + form_content = {$smarty.capture.delete_feature_dialog nofilter} +} + + diff --git a/templates/admin/default/ajax/thelia_news_feed.html b/templates/admin/default/ajax/thelia_news_feed.html new file mode 100755 index 000000000..f1b7e3133 --- /dev/null +++ b/templates/admin/default/ajax/thelia_news_feed.html @@ -0,0 +1,26 @@ +{* this temlate is loaded via Ajax in the login page, to prevent login page slowdown *} + +
+ {loop type="feed" name="thelia_feeds" url="http://thelia.net/Flux-rss.html?id_rubrique=8" limit="3"} + +
+ +
+
+ {* we use unescape:"htmlall" to unescape var before truncate, to prevent a cut in the middel of an HTML entity, eg &ea... *} +

{$DESCRIPTION|strip_tags|unescape:"htmlall"|truncate:250:"...":true nofilter}

+
+ +
+
+ + {/loop} +
\ No newline at end of file diff --git a/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js b/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js index bf3a56df0..97a3d67ed 100755 --- a/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js +++ b/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js @@ -1,474 +1,474 @@ -/* ========================================================= - * bootstrap-datepicker.js - * http://www.eyecon.ro/bootstrap-datepicker - * ========================================================= - * Copyright 2012 Stefan Petre - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================================================= */ - -!function( $ ) { - - // Picker object - - var Datepicker = function(element, options){ - this.element = $(element); - this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy'); - this.picker = $(DPGlobal.template) - .appendTo('body') - .on({ - click: $.proxy(this.click, this)//, - //mousedown: $.proxy(this.mousedown, this) - }); - this.isInput = this.element.is('input'); - this.component = this.element.is('.date') ? this.element.find('.add-on') : false; - - if (this.isInput) { - this.element.on({ - focus: $.proxy(this.show, this), - //blur: $.proxy(this.hide, this), - keyup: $.proxy(this.update, this) - }); - } else { - if (this.component){ - this.component.on('click', $.proxy(this.show, this)); - } else { - this.element.on('click', $.proxy(this.show, this)); - } - } - - this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0; - if (typeof this.minViewMode === 'string') { - switch (this.minViewMode) { - case 'months': - this.minViewMode = 1; - break; - case 'years': - this.minViewMode = 2; - break; - default: - this.minViewMode = 0; - break; - } - } - this.viewMode = options.viewMode||this.element.data('date-viewmode')||0; - if (typeof this.viewMode === 'string') { - switch (this.viewMode) { - case 'months': - this.viewMode = 1; - break; - case 'years': - this.viewMode = 2; - break; - default: - this.viewMode = 0; - break; - } - } - this.startViewMode = this.viewMode; - this.weekStart = options.weekStart||this.element.data('date-weekstart')||0; - this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; - this.onRender = options.onRender; - this.fillDow(); - this.fillMonths(); - this.update(); - this.showMode(); - }; - - Datepicker.prototype = { - constructor: Datepicker, - - show: function(e) { - this.picker.show(); - this.height = this.component ? this.component.outerHeight() : this.element.outerHeight(); - this.place(); - $(window).on('resize', $.proxy(this.place, this)); - if (e ) { - e.stopPropagation(); - e.preventDefault(); - } - if (!this.isInput) { - } - var that = this; - $(document).on('mousedown', function(ev){ - if ($(ev.target).closest('.datepicker').length == 0) { - that.hide(); - } - }); - this.element.trigger({ - type: 'show', - date: this.date - }); - }, - - hide: function(){ - this.picker.hide(); - $(window).off('resize', this.place); - this.viewMode = this.startViewMode; - this.showMode(); - if (!this.isInput) { - $(document).off('mousedown', this.hide); - } - //this.set(); - this.element.trigger({ - type: 'hide', - date: this.date - }); - }, - - set: function() { - var formated = DPGlobal.formatDate(this.date, this.format); - if (!this.isInput) { - if (this.component){ - this.element.find('input').prop('value', formated); - } - this.element.data('date', formated); - } else { - this.element.prop('value', formated); - } - }, - - setValue: function(newDate) { - if (typeof newDate === 'string') { - this.date = DPGlobal.parseDate(newDate, this.format); - } else { - this.date = new Date(newDate); - } - this.set(); - this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); - this.fill(); - }, - - place: function(){ - var offset = this.component ? this.component.offset() : this.element.offset(); - this.picker.css({ - top: offset.top + this.height, - left: offset.left - }); - }, - - update: function(newDate){ - this.date = DPGlobal.parseDate( - typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')), - this.format - ); - this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); - this.fill(); - }, - - fillDow: function(){ - var dowCnt = this.weekStart; - var html = ''; - while (dowCnt < this.weekStart + 7) { - html += ''+DPGlobal.dates.daysMin[(dowCnt++)%7]+''; - } - html += ''; - this.picker.find('.datepicker-days thead').append(html); - }, - - fillMonths: function(){ - var html = ''; - var i = 0 - while (i < 12) { - html += ''+DPGlobal.dates.monthsShort[i++]+''; - } - this.picker.find('.datepicker-months td').append(html); - }, - - fill: function() { - var d = new Date(this.viewDate), - year = d.getFullYear(), - month = d.getMonth(), - currentDate = this.date.valueOf(); - this.picker.find('.datepicker-days th:eq(1)') - .text(DPGlobal.dates.months[month]+' '+year); - var prevMonth = new Date(year, month-1, 28,0,0,0,0), - day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth()); - prevMonth.setDate(day); - prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7); - var nextMonth = new Date(prevMonth); - nextMonth.setDate(nextMonth.getDate() + 42); - nextMonth = nextMonth.valueOf(); - var html = []; - var clsName, - prevY, - prevM; - while(prevMonth.valueOf() < nextMonth) { - if (prevMonth.getDay() === this.weekStart) { - html.push(''); - } - clsName = this.onRender(prevMonth); - prevY = prevMonth.getFullYear(); - prevM = prevMonth.getMonth(); - if ((prevM < month && prevY === year) || prevY < year) { - clsName += ' old'; - } else if ((prevM > month && prevY === year) || prevY > year) { - clsName += ' new'; - } - if (prevMonth.valueOf() === currentDate) { - clsName += ' active'; - } - html.push(''+prevMonth.getDate() + ''); - if (prevMonth.getDay() === this.weekEnd) { - html.push(''); - } - prevMonth.setDate(prevMonth.getDate()+1); - } - this.picker.find('.datepicker-days tbody').empty().append(html.join('')); - var currentYear = this.date.getFullYear(); - - var months = this.picker.find('.datepicker-months') - .find('th:eq(1)') - .text(year) - .end() - .find('span').removeClass('active'); - if (currentYear === year) { - months.eq(this.date.getMonth()).addClass('active'); - } - - html = ''; - year = parseInt(year/10, 10) * 10; - var yearCont = this.picker.find('.datepicker-years') - .find('th:eq(1)') - .text(year + '-' + (year + 9)) - .end() - .find('td'); - year -= 1; - for (var i = -1; i < 11; i++) { - html += ''+year+''; - year += 1; - } - yearCont.html(html); - }, - - click: function(e) { - e.stopPropagation(); - e.preventDefault(); - var target = $(e.target).closest('span, td, th'); - if (target.length === 1) { - switch(target[0].nodeName.toLowerCase()) { - case 'th': - switch(target[0].className) { - case 'switch': - this.showMode(1); - break; - case 'prev': - case 'next': - this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call( - this.viewDate, - this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) + - DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1) - ); - this.fill(); - this.set(); - break; - } - break; - case 'span': - if (target.is('.month')) { - var month = target.parent().find('span').index(target); - this.viewDate.setMonth(month); - } else { - var year = parseInt(target.text(), 10)||0; - this.viewDate.setFullYear(year); - } - if (this.viewMode !== 0) { - this.date = new Date(this.viewDate); - this.element.trigger({ - type: 'changeDate', - date: this.date, - viewMode: DPGlobal.modes[this.viewMode].clsName - }); - } - this.showMode(-1); - this.fill(); - this.set(); - break; - case 'td': - if (target.is('.day') && !target.is('.disabled')){ - var day = parseInt(target.text(), 10)||1; - var month = this.viewDate.getMonth(); - if (target.is('.old')) { - month -= 1; - } else if (target.is('.new')) { - month += 1; - } - var year = this.viewDate.getFullYear(); - this.date = new Date(year, month, day,0,0,0,0); - this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0); - this.fill(); - this.set(); - this.element.trigger({ - type: 'changeDate', - date: this.date, - viewMode: DPGlobal.modes[this.viewMode].clsName - }); - } - break; - } - } - }, - - mousedown: function(e){ - e.stopPropagation(); - e.preventDefault(); - }, - - showMode: function(dir) { - if (dir) { - this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir)); - } - this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show(); - } - }; - - $.fn.datepicker = function ( option, val ) { - return this.each(function () { - var $this = $(this), - data = $this.data('datepicker'), - options = typeof option === 'object' && option; - if (!data) { - $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options)))); - } - if (typeof option === 'string') data[option](val); - }); - }; - - $.fn.datepicker.defaults = { - onRender: function(date) { - return ''; - } - }; - $.fn.datepicker.Constructor = Datepicker; - - var DPGlobal = { - modes: [ - { - clsName: 'days', - navFnc: 'Month', - navStep: 1 - }, - { - clsName: 'months', - navFnc: 'FullYear', - navStep: 1 - }, - { - clsName: 'years', - navFnc: 'FullYear', - navStep: 10 - }], - dates:{ - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], - daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], - daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], - months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] - }, - isLeapYear: function (year) { - return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) - }, - getDaysInMonth: function (year, month) { - return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] - }, - parseFormat: function(format){ - var separator = format.match(/[.\/\-\s].*?/), - parts = format.split(/\W+/); - if (!separator || !parts || parts.length === 0){ - throw new Error("Invalid date format."); - } - return {separator: separator, parts: parts}; - }, - parseDate: function(date, format) { - var parts = date.split(format.separator), - date = new Date(), - val; - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - date.setMilliseconds(0); - if (parts.length === format.parts.length) { - var year = date.getFullYear(), day = date.getDate(), month = date.getMonth(); - for (var i=0, cnt = format.parts.length; i < cnt; i++) { - val = parseInt(parts[i], 10)||1; - switch(format.parts[i]) { - case 'dd': - case 'd': - day = val; - date.setDate(val); - break; - case 'mm': - case 'm': - month = val - 1; - date.setMonth(val - 1); - break; - case 'yy': - year = 2000 + val; - date.setFullYear(2000 + val); - break; - case 'yyyy': - year = val; - date.setFullYear(val); - break; - } - } - date = new Date(year, month, day, 0 ,0 ,0); - } - return date; - }, - formatDate: function(date, format){ - var val = { - d: date.getDate(), - m: date.getMonth() + 1, - yy: date.getFullYear().toString().substring(2), - yyyy: date.getFullYear() - }; - val.dd = (val.d < 10 ? '0' : '') + val.d; - val.mm = (val.m < 10 ? '0' : '') + val.m; - var date = []; - for (var i=0, cnt = format.parts.length; i < cnt; i++) { - date.push(val[format.parts[i]]); - } - return date.join(format.separator); - }, - headTemplate: ''+ - ''+ - '‹'+ - ''+ - '›'+ - ''+ - '', - contTemplate: '' - }; - DPGlobal.template = ''; - -}( window.jQuery ); \ No newline at end of file +///* ========================================================= +// * bootstrap-datepicker.js +// * http://www.eyecon.ro/bootstrap-datepicker +// * ========================================================= +// * Copyright 2012 Stefan Petre +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// * ========================================================= */ +// +//!function( $ ) { +// +// // Picker object +// +// var Datepicker = function(element, options){ +// this.element = $(element); +// this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy'); +// this.picker = $(DPGlobal.template) +// .appendTo('body') +// .on({ +// click: $.proxy(this.click, this)//, +// //mousedown: $.proxy(this.mousedown, this) +// }); +// this.isInput = this.element.is('input'); +// this.component = this.element.is('.date') ? this.element.find('.add-on') : false; +// +// if (this.isInput) { +// this.element.on({ +// focus: $.proxy(this.show, this), +// //blur: $.proxy(this.hide, this), +// keyup: $.proxy(this.update, this) +// }); +// } else { +// if (this.component){ +// this.component.on('click', $.proxy(this.show, this)); +// } else { +// this.element.on('click', $.proxy(this.show, this)); +// } +// } +// +// this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0; +// if (typeof this.minViewMode === 'string') { +// switch (this.minViewMode) { +// case 'months': +// this.minViewMode = 1; +// break; +// case 'years': +// this.minViewMode = 2; +// break; +// default: +// this.minViewMode = 0; +// break; +// } +// } +// this.viewMode = options.viewMode||this.element.data('date-viewmode')||0; +// if (typeof this.viewMode === 'string') { +// switch (this.viewMode) { +// case 'months': +// this.viewMode = 1; +// break; +// case 'years': +// this.viewMode = 2; +// break; +// default: +// this.viewMode = 0; +// break; +// } +// } +// this.startViewMode = this.viewMode; +// this.weekStart = options.weekStart||this.element.data('date-weekstart')||0; +// this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; +// this.onRender = options.onRender; +// this.fillDow(); +// this.fillMonths(); +// this.update(); +// this.showMode(); +// }; +// +// Datepicker.prototype = { +// constructor: Datepicker, +// +// show: function(e) { +// this.picker.show(); +// this.height = this.component ? this.component.outerHeight() : this.element.outerHeight(); +// this.place(); +// $(window).on('resize', $.proxy(this.place, this)); +// if (e ) { +// e.stopPropagation(); +// e.preventDefault(); +// } +// if (!this.isInput) { +// } +// var that = this; +// $(document).on('mousedown', function(ev){ +// if ($(ev.target).closest('.datepicker').length == 0) { +// that.hide(); +// } +// }); +// this.element.trigger({ +// type: 'show', +// date: this.date +// }); +// }, +// +// hide: function(){ +// this.picker.hide(); +// $(window).off('resize', this.place); +// this.viewMode = this.startViewMode; +// this.showMode(); +// if (!this.isInput) { +// $(document).off('mousedown', this.hide); +// } +// //this.set(); +// this.element.trigger({ +// type: 'hide', +// date: this.date +// }); +// }, +// +// set: function() { +// var formated = DPGlobal.formatDate(this.date, this.format); +// if (!this.isInput) { +// if (this.component){ +// this.element.find('input').prop('value', formated); +// } +// this.element.data('date', formated); +// } else { +// this.element.prop('value', formated); +// } +// }, +// +// setValue: function(newDate) { +// if (typeof newDate === 'string') { +// this.date = DPGlobal.parseDate(newDate, this.format); +// } else { +// this.date = new Date(newDate); +// } +// this.set(); +// this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); +// this.fill(); +// }, +// +// place: function(){ +// var offset = this.component ? this.component.offset() : this.element.offset(); +// this.picker.css({ +// top: offset.top + this.height, +// left: offset.left +// }); +// }, +// +// update: function(newDate){ +// this.date = DPGlobal.parseDate( +// typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')), +// this.format +// ); +// this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); +// this.fill(); +// }, +// +// fillDow: function(){ +// var dowCnt = this.weekStart; +// var html = ''; +// while (dowCnt < this.weekStart + 7) { +// html += ''+DPGlobal.dates.daysMin[(dowCnt++)%7]+''; +// } +// html += ''; +// this.picker.find('.datepicker-days thead').append(html); +// }, +// +// fillMonths: function(){ +// var html = ''; +// var i = 0 +// while (i < 12) { +// html += ''+DPGlobal.dates.monthsShort[i++]+''; +// } +// this.picker.find('.datepicker-months td').append(html); +// }, +// +// fill: function() { +// var d = new Date(this.viewDate), +// year = d.getFullYear(), +// month = d.getMonth(), +// currentDate = this.date.valueOf(); +// this.picker.find('.datepicker-days th:eq(1)') +// .text(DPGlobal.dates.months[month]+' '+year); +// var prevMonth = new Date(year, month-1, 28,0,0,0,0), +// day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth()); +// prevMonth.setDate(day); +// prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7); +// var nextMonth = new Date(prevMonth); +// nextMonth.setDate(nextMonth.getDate() + 42); +// nextMonth = nextMonth.valueOf(); +// var html = []; +// var clsName, +// prevY, +// prevM; +// while(prevMonth.valueOf() < nextMonth) { +// if (prevMonth.getDay() === this.weekStart) { +// html.push(''); +// } +// clsName = this.onRender(prevMonth); +// prevY = prevMonth.getFullYear(); +// prevM = prevMonth.getMonth(); +// if ((prevM < month && prevY === year) || prevY < year) { +// clsName += ' old'; +// } else if ((prevM > month && prevY === year) || prevY > year) { +// clsName += ' new'; +// } +// if (prevMonth.valueOf() === currentDate) { +// clsName += ' active'; +// } +// html.push(''+prevMonth.getDate() + ''); +// if (prevMonth.getDay() === this.weekEnd) { +// html.push(''); +// } +// prevMonth.setDate(prevMonth.getDate()+1); +// } +// this.picker.find('.datepicker-days tbody').empty().append(html.join('')); +// var currentYear = this.date.getFullYear(); +// +// var months = this.picker.find('.datepicker-months') +// .find('th:eq(1)') +// .text(year) +// .end() +// .find('span').removeClass('active'); +// if (currentYear === year) { +// months.eq(this.date.getMonth()).addClass('active'); +// } +// +// html = ''; +// year = parseInt(year/10, 10) * 10; +// var yearCont = this.picker.find('.datepicker-years') +// .find('th:eq(1)') +// .text(year + '-' + (year + 9)) +// .end() +// .find('td'); +// year -= 1; +// for (var i = -1; i < 11; i++) { +// html += ''+year+''; +// year += 1; +// } +// yearCont.html(html); +// }, +// +// click: function(e) { +// e.stopPropagation(); +// e.preventDefault(); +// var target = $(e.target).closest('span, td, th'); +// if (target.length === 1) { +// switch(target[0].nodeName.toLowerCase()) { +// case 'th': +// switch(target[0].className) { +// case 'switch': +// this.showMode(1); +// break; +// case 'prev': +// case 'next': +// this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call( +// this.viewDate, +// this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) + +// DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1) +// ); +// this.fill(); +// this.set(); +// break; +// } +// break; +// case 'span': +// if (target.is('.month')) { +// var month = target.parent().find('span').index(target); +// this.viewDate.setMonth(month); +// } else { +// var year = parseInt(target.text(), 10)||0; +// this.viewDate.setFullYear(year); +// } +// if (this.viewMode !== 0) { +// this.date = new Date(this.viewDate); +// this.element.trigger({ +// type: 'changeDate', +// date: this.date, +// viewMode: DPGlobal.modes[this.viewMode].clsName +// }); +// } +// this.showMode(-1); +// this.fill(); +// this.set(); +// break; +// case 'td': +// if (target.is('.day') && !target.is('.disabled')){ +// var day = parseInt(target.text(), 10)||1; +// var month = this.viewDate.getMonth(); +// if (target.is('.old')) { +// month -= 1; +// } else if (target.is('.new')) { +// month += 1; +// } +// var year = this.viewDate.getFullYear(); +// this.date = new Date(year, month, day,0,0,0,0); +// this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0); +// this.fill(); +// this.set(); +// this.element.trigger({ +// type: 'changeDate', +// date: this.date, +// viewMode: DPGlobal.modes[this.viewMode].clsName +// }); +// } +// break; +// } +// } +// }, +// +// mousedown: function(e){ +// e.stopPropagation(); +// e.preventDefault(); +// }, +// +// showMode: function(dir) { +// if (dir) { +// this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir)); +// } +// this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show(); +// } +// }; +// +// $.fn.datepicker = function ( option, val ) { +// return this.each(function () { +// var $this = $(this), +// data = $this.data('datepicker'), +// options = typeof option === 'object' && option; +// if (!data) { +// $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options)))); +// } +// if (typeof option === 'string') data[option](val); +// }); +// }; +// +// $.fn.datepicker.defaults = { +// onRender: function(date) { +// return ''; +// } +// }; +// $.fn.datepicker.Constructor = Datepicker; +// +// var DPGlobal = { +// modes: [ +// { +// clsName: 'days', +// navFnc: 'Month', +// navStep: 1 +// }, +// { +// clsName: 'months', +// navFnc: 'FullYear', +// navStep: 1 +// }, +// { +// clsName: 'years', +// navFnc: 'FullYear', +// navStep: 10 +// }], +// dates:{ +// days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], +// daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], +// daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], +// months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], +// monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +// }, +// isLeapYear: function (year) { +// return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) +// }, +// getDaysInMonth: function (year, month) { +// return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] +// }, +// parseFormat: function(format){ +// var separator = format.match(/[.\/\-\s].*?/), +// parts = format.split(/\W+/); +// if (!separator || !parts || parts.length === 0){ +// throw new Error("Invalid date format."); +// } +// return {separator: separator, parts: parts}; +// }, +// parseDate: function(date, format) { +// var parts = date.split(format.separator), +// date = new Date(), +// val; +// date.setHours(0); +// date.setMinutes(0); +// date.setSeconds(0); +// date.setMilliseconds(0); +// if (parts.length === format.parts.length) { +// var year = date.getFullYear(), day = date.getDate(), month = date.getMonth(); +// for (var i=0, cnt = format.parts.length; i < cnt; i++) { +// val = parseInt(parts[i], 10)||1; +// switch(format.parts[i]) { +// case 'dd': +// case 'd': +// day = val; +// date.setDate(val); +// break; +// case 'mm': +// case 'm': +// month = val - 1; +// date.setMonth(val - 1); +// break; +// case 'yy': +// year = 2000 + val; +// date.setFullYear(2000 + val); +// break; +// case 'yyyy': +// year = val; +// date.setFullYear(val); +// break; +// } +// } +// date = new Date(year, month, day, 0 ,0 ,0); +// } +// return date; +// }, +// formatDate: function(date, format){ +// var val = { +// d: date.getDate(), +// m: date.getMonth() + 1, +// yy: date.getFullYear().toString().substring(2), +// yyyy: date.getFullYear() +// }; +// val.dd = (val.d < 10 ? '0' : '') + val.d; +// val.mm = (val.m < 10 ? '0' : '') + val.m; +// var date = []; +// for (var i=0, cnt = format.parts.length; i < cnt; i++) { +// date.push(val[format.parts[i]]); +// } +// return date.join(format.separator); +// }, +// headTemplate: ''+ +// ''+ +// '‹'+ +// ''+ +// '›'+ +// ''+ +// '', +// contTemplate: '' +// }; +// DPGlobal.template = ''; +// +//}( window.jQuery ); \ No newline at end of file diff --git a/templates/admin/default/assets/js/bootstrap-select/bootstrap-select.js b/templates/admin/default/assets/js/bootstrap-select/bootstrap-select.js new file mode 100644 index 000000000..dcfd633a0 --- /dev/null +++ b/templates/admin/default/assets/js/bootstrap-select/bootstrap-select.js @@ -0,0 +1,709 @@ +/*! + * bootstrap-select v1.3.1 + * http://silviomoreto.github.io/bootstrap-select/ + * + * Copyright 2013 bootstrap-select + * Licensed under the MIT license + */ + +!function($) { + + "use strict"; + + $.expr[":"].icontains = $.expr.createPseudo(function(arg) { + return function( elem ) { + return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; + }; + }); + + var Selectpicker = function(element, options, e) { + if (e) { + e.stopPropagation(); + e.preventDefault(); + } + this.$element = $(element); + this.$newElement = null; + this.$button = null; + this.$menu = null; + + //Merge defaults, options and data-attributes to make our options + this.options = $.extend({}, $.fn.selectpicker.defaults, this.$element.data(), typeof options == 'object' && options); + + //If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute + if (this.options.title == null) { + this.options.title = this.$element.attr('title'); + } + + //Expose public methods + this.val = Selectpicker.prototype.val; + this.render = Selectpicker.prototype.render; + this.refresh = Selectpicker.prototype.refresh; + this.setStyle = Selectpicker.prototype.setStyle; + this.selectAll = Selectpicker.prototype.selectAll; + this.deselectAll = Selectpicker.prototype.deselectAll; + this.init(); + }; + + Selectpicker.prototype = { + + constructor: Selectpicker, + + init: function(e) { + this.$element.hide(); + this.multiple = this.$element.prop('multiple'); + var id = this.$element.attr('id'); + this.$newElement = this.createView(); + this.$element.after(this.$newElement); + this.$menu = this.$newElement.find('> .dropdown-menu'); + this.$button = this.$newElement.find('> button'); + this.$searchbox = this.$newElement.find('input'); + + if (id !== undefined) { + var that = this; + this.$button.attr('data-id', id); + $('label[for="' + id + '"]').click(function(e) { + e.preventDefault(); + that.$button.focus(); + }); + } + + this.checkDisabled(); + this.checkTabIndex(); + this.clickListener(); + this.liveSearchListener(); + this.render(); + this.liHeight(); + this.setStyle(); + this.setWidth(); + if (this.options.container) { + this.selectPosition(); + } + this.$menu.data('this', this); + this.$newElement.data('this', this); + }, + + createDropdown: function() { + //If we are multiple, then add the show-tick class by default + var multiple = this.multiple ? ' show-tick' : ''; + var header = this.options.header ? '

' + this.options.header + '

' : ''; + var searchbox = this.options.liveSearch ? '' : ''; + var drop = + "
" + + "" + + "" + + "
"; + + return $(drop); + }, + + createView: function() { + var $drop = this.createDropdown(); + var $li = this.createLi(); + $drop.find('ul').append($li); + return $drop; + }, + + reloadLi: function() { + //Remove all children. + this.destroyLi(); + //Re build + var $li = this.createLi(); + this.$menu.find('ul').append( $li ); + }, + + destroyLi: function() { + this.$menu.find('li').remove(); + }, + + createLi: function() { + var that = this, + _liA = [], + _liHtml = ''; + + this.$element.find('option').each(function(index) { + var $this = $(this); + + //Get the class and text for the option + var optionClass = $this.attr("class") || ''; + var inline = $this.attr("style") || ''; + var text = $this.data('content') ? $this.data('content') : $this.html(); + var subtext = $this.data('subtext') !== undefined ? '' + $this.data('subtext') + '' : ''; + var icon = $this.data('icon') !== undefined ? ' ' : ''; + if (icon !== '' && ($this.is(':disabled') || $this.parent().is(':disabled'))) { + icon = ''+icon+''; + } + + if (!$this.data('content')) { + //Prepend any icon and append any subtext to the main text. + text = icon + '' + text + subtext + ''; + } + + if (that.options.hideDisabled && ($this.is(':disabled') || $this.parent().is(':disabled'))) { + _liA.push(''); + } else if ($this.parent().is('optgroup') && $this.data('divider') != true) { + if ($this.index() == 0) { + //Get the opt group label + var label = $this.parent().attr('label'); + var labelSubtext = $this.parent().data('subtext') !== undefined ? ''+$this.parent().data('subtext')+'' : ''; + var labelIcon = $this.parent().data('icon') ? ' ' : ''; + label = labelIcon + '' + label + labelSubtext + ''; + + if ($this[0].index != 0) { + _liA.push( + '
'+ + '
'+label+'
'+ + that.createA(text, "opt " + optionClass, inline ) + ); + } else { + _liA.push( + '
'+label+'
'+ + that.createA(text, "opt " + optionClass, inline )); + } + } else { + _liA.push(that.createA(text, "opt " + optionClass, inline )); + } + } else if ($this.data('divider') == true) { + _liA.push('
'); + } else if ($(this).data('hidden') == true) { + _liA.push(''); + } else { + _liA.push(that.createA(text, optionClass, inline )); + } + }); + + $.each(_liA, function(i, item) { + _liHtml += "
  • " + item + "
  • "; + }); + + //If we are not multiple, and we dont have a selected item, and we dont have a title, select the first element so something is set in the button + if (!this.multiple && this.$element.find('option:selected').length==0 && !this.options.title) { + this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected'); + } + + return $(_liHtml); + }, + + createA: function(text, classes, inline) { + return '' + + text + + '' + + ''; + }, + + render: function() { + var that = this; + + //Update the LI to match the SELECT + this.$element.find('option').each(function(index) { + that.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled') ); + that.setSelected(index, $(this).is(':selected') ); + }); + + var selectedItems = this.$element.find('option:selected').map(function(index,value) { + var $this = $(this); + var icon = $this.data('icon') && that.options.showIcon ? ' ' : ''; + var subtext; + if (that.options.showSubtext && $this.attr('data-subtext') && !that.multiple) { + subtext = ' '+$this.data('subtext') +''; + } else { + subtext = ''; + } + if ($this.data('content') && that.options.showContent) { + return $this.data('content'); + } else if ($this.attr('title') != undefined) { + return $this.attr('title'); + } else { + return icon + $this.html() + subtext; + } + }).toArray(); + + //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled + //Convert all the values into a comma delimited string + var title = !this.multiple ? selectedItems[0] : selectedItems.join(", "); + + //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc.. + if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) { + var max = this.options.selectedTextFormat.split(">"); + var notDisabled = this.options.hideDisabled ? ':not([disabled])' : ''; + if ( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) { + title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"]):not([data-hidden="true"])'+notDisabled).length); + } + } + + //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text + if (!title) { + title = this.options.title != undefined ? this.options.title : this.options.noneSelectedText; + } + + this.$newElement.find('.filter-option').html(title); + }, + + setStyle: function(style, status) { + if (this.$element.attr('class')) { + this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device/gi, '')); + } + + var buttonClass = style ? style : this.options.style; + + if (status == 'add') { + this.$button.addClass(buttonClass); + } else if (status == 'remove') { + this.$button.removeClass(buttonClass); + } else { + this.$button.removeClass(this.options.style); + this.$button.addClass(buttonClass); + } + }, + + liHeight: function() { + var selectClone = this.$newElement.clone(); + selectClone.appendTo('body'); + var $menuClone = selectClone.addClass('open').find('> .dropdown-menu'); + var liHeight = $menuClone.find('li > a').outerHeight(); + var headerHeight = this.options.header ? $menuClone.find('.popover-title').outerHeight() : 0; + selectClone.remove(); + this.$newElement.data('liHeight', liHeight).data('headerHeight', headerHeight); + }, + + setSize: function() { + var that = this, + menu = this.$menu, + menuInner = menu.find('.inner'), + menuA = menuInner.find('li > a'), + selectHeight = this.$newElement.outerHeight(), + liHeight = this.$newElement.data('liHeight'), + headerHeight = this.$newElement.data('headerHeight'), + divHeight = menu.find('li .divider').outerHeight(true), + menuPadding = parseInt(menu.css('padding-top')) + + parseInt(menu.css('padding-bottom')) + + parseInt(menu.css('border-top-width')) + + parseInt(menu.css('border-bottom-width')), + notDisabled = this.options.hideDisabled ? ':not(.disabled)' : '', + $window = $(window), + menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2, + menuHeight, + selectOffsetTop, + selectOffsetBot, + posVert = function() { + selectOffsetTop = that.$newElement.offset().top - $window.scrollTop(); + selectOffsetBot = $window.height() - selectOffsetTop - selectHeight; + }; + posVert(); + if (this.options.header) menu.css('padding-top', 0); + + if (this.options.size == 'auto') { + var getSize = function() { + var minHeight; + posVert(); + menuHeight = selectOffsetBot - menuExtras; + that.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight - menuExtras) < menu.height() && that.options.dropupAuto); + if (that.$newElement.hasClass('dropup')) { + menuHeight = selectOffsetTop - menuExtras; + } + if ((menu.find('li').length + menu.find('dt').length) > 3) { + minHeight = liHeight*3 + menuExtras - 2; + } else { + minHeight = 0; + } + menu.css({'max-height' : menuHeight + 'px', 'overflow' : 'hidden', 'min-height' : minHeight + 'px'}); + menuInner.css({'max-height' : menuHeight - headerHeight- menuPadding + 'px', 'overflow-y' : 'auto', 'min-height' : minHeight - menuPadding + 'px'}); + } + getSize(); + $(window).resize(getSize); + $(window).scroll(getSize); + } else if (this.options.size && this.options.size != 'auto' && menu.find('li'+notDisabled).length > this.options.size) { + var optIndex = menu.find("li"+notDisabled+" > *").filter(':not(.div-contain)').slice(0,this.options.size).last().parent().index(); + var divLength = menu.find("li").slice(0,optIndex + 1).find('.div-contain').length; + menuHeight = liHeight*this.options.size + divLength*divHeight + menuPadding; + this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && menuHeight < menu.height() && this.options.dropupAuto); + menu.css({'max-height' : menuHeight + headerHeight + 'px', 'overflow' : 'hidden'}); + menuInner.css({'max-height' : menuHeight - menuPadding + 'px', 'overflow-y' : 'auto'}); + } + }, + + setWidth: function() { + if (this.options.width == 'auto') { + this.$menu.css('min-width', '0'); + + // Get correct width if element hidden + var selectClone = this.$newElement.clone().appendTo('body'); + var ulWidth = selectClone.find('> .dropdown-menu').css('width'); + selectClone.remove(); + + this.$newElement.css('width', ulWidth); + } else if (this.options.width == 'fit') { + // Remove inline min-width so width can be changed from 'auto' + this.$menu.css('min-width', ''); + this.$newElement.css('width', '').addClass('fit-width'); + } else if (this.options.width) { + // Remove inline min-width so width can be changed from 'auto' + this.$menu.css('min-width', ''); + this.$newElement.css('width', this.options.width); + } else { + // Remove inline min-width/width so width can be changed + this.$menu.css('min-width', ''); + this.$newElement.css('width', ''); + } + // Remove fit-width class if width is changed programmatically + if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { + this.$newElement.removeClass('fit-width'); + } + }, + + selectPosition: function() { + var that = this, + drop = "
    ", + $drop = $(drop), + pos, + actualHeight, + getPlacement = function($element) { + $drop.addClass($element.attr('class')).toggleClass('dropup', $element.hasClass('dropup')); + pos = $element.offset(); + actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight; + $drop.css({'top' : pos.top + actualHeight, 'left' : pos.left, 'width' : $element[0].offsetWidth, 'position' : 'absolute'}); + }; + this.$newElement.on('click', function(e) { + getPlacement($(this)); + $drop.appendTo(that.options.container); + $drop.toggleClass('open', !$(this).hasClass('open')); + $drop.append(that.$menu); + }); + $(window).resize(function() { + getPlacement(that.$newElement); + }); + $(window).on('scroll', function(e) { + getPlacement(that.$newElement); + }); + $('html').on('click', function(e) { + if ($(e.target).closest(that.$newElement).length < 1) { + $drop.removeClass('open'); + } + }); + }, + + mobile: function() { + this.$element.addClass('mobile-device').appendTo(this.$newElement); + if (this.options.container) this.$menu.hide(); + }, + + refresh: function() { + this.reloadLi(); + this.render(); + this.setWidth(); + this.setStyle(); + this.checkDisabled(); + this.liHeight(); + }, + + setSelected: function(index, selected) { + this.$menu.find('li').eq(index).toggleClass('selected', selected); + }, + + setDisabled: function(index, disabled) { + if (disabled) { + this.$menu.find('li').eq(index).addClass('disabled').find('a').attr('href','#').attr('tabindex',-1); + } else { + this.$menu.find('li').eq(index).removeClass('disabled').find('a').removeAttr('href').attr('tabindex',0); + } + }, + + isDisabled: function() { + return this.$element.is(':disabled'); + }, + + checkDisabled: function() { + var that = this; + if (this.isDisabled()) { + this.$button.addClass('disabled'); + this.$button.attr('tabindex','-1'); + } else if (this.$button.hasClass('disabled')) { + this.$button.removeClass('disabled'); + this.$button.removeAttr('tabindex'); + } + this.$button.click(function() { + return !that.isDisabled(); + }); + }, + + checkTabIndex: function() { + if (this.$element.is('[tabindex]')) { + var tabindex = this.$element.attr("tabindex"); + this.$button.attr('tabindex', tabindex); + } + }, + + clickListener: function() { + var that = this; + + $('body').on('touchstart.dropdown', '.dropdown-menu', function(e) { + e.stopPropagation(); + }); + + this.$newElement.on('click', function() { + that.setSize(); + }); + + this.$menu.on('click', 'li a', function(e) { + var clickedIndex = $(this).parent().index(), + $this = $(this).parent(), + prevValue = that.$element.val(); + + //Dont close on multi choice menu + if (that.multiple) { + e.stopPropagation(); + } + + e.preventDefault(); + + //Dont run if we have been disabled + if (!that.isDisabled() && !$(this).parent().hasClass('disabled')) { + var $options = that.$element.find('option'); + var $option = $options.eq(clickedIndex); + + //Deselect all others if not multi select box + if (!that.multiple) { + $options.prop('selected', false); + $option.prop('selected', true); + } + //Else toggle the one we have chosen if we are multi select. + else { + var state = $option.prop('selected'); + + $option.prop('selected', !state); + } + + that.$button.focus(); + + // Trigger select 'change' + if (prevValue != that.$element.val()) { + that.$element.change(); + } + } + }); + + this.$menu.on('click', 'li.disabled a, li dt, li .div-contain, h3.popover-title', function(e) { + if (e.target == this) { + e.preventDefault(); + e.stopPropagation(); + that.$button.focus(); + } + }); + + this.$searchbox.on('click', function(e) { + e.stopPropagation(); + }); + + this.$element.change(function() { + that.render() + }); + }, + + liveSearchListener: function() { + var that = this; + + this.$newElement.on('click.dropdown.data-api', function(e){ + if(that.options.liveSearch) { + setTimeout(function() { + that.$searchbox.focus(); + }, 10); + } + }); + + this.$searchbox.on('input', function() { + that.$newElement.find('li').show().not(':icontains(' + that.$searchbox.val() + ')').hide(); + }); + }, + + val: function(value) { + + if (value != undefined) { + this.$element.val( value ); + + this.$element.change(); + return this.$element; + } else { + return this.$element.val(); + } + }, + + selectAll: function() { + this.$element.find('option').prop('selected', true).attr('selected', 'selected'); + this.render(); + }, + + deselectAll: function() { + this.$element.find('option').prop('selected', false).removeAttr('selected'); + this.render(); + }, + + keydown: function(e) { + var $this, + $items, + $parent, + index, + next, + first, + last, + prev, + nextPrev, + that; + + $this = $(this); + + $parent = $this.parent(); + + that = $parent.data('this'); + + if (that.options.container) $parent = that.$menu; + + $items = $('[role=menu] li:not(.divider):visible a', $parent); + + if (!$items.length) return; + + if (/(38|40)/.test(e.keyCode)) { + + index = $items.index($items.filter(':focus')); + first = $items.parent(':not(.disabled)').first().index(); + last = $items.parent(':not(.disabled)').last().index(); + next = $items.eq(index).parent().nextAll(':not(.disabled)').eq(0).index(); + prev = $items.eq(index).parent().prevAll(':not(.disabled)').eq(0).index(); + nextPrev = $items.eq(next).parent().prevAll(':not(.disabled)').eq(0).index(); + + if (e.keyCode == 38) { + if (index != nextPrev && index > prev) index = prev; + if (index < first) index = first; + } + + if (e.keyCode == 40) { + if (index != nextPrev && index < next) index = next; + if (index > last) index = last; + if (index == -1) index = 0; + } + + $items.eq(index).focus(); + } else { + var keyCodeMap = { + 48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", 59:";", + 65:"a", 66:"b", 67:"c", 68:"d", 69:"e", 70:"f", 71:"g", 72:"h", 73:"i", 74:"j", 75:"k", 76:"l", + 77:"m", 78:"n", 79:"o", 80:"p", 81:"q", 82:"r", 83:"s", 84:"t", 85:"u", 86:"v", 87:"w", 88:"x", 89:"y", 90:"z", + 96:"0", 97:"1", 98:"2", 99:"3", 100:"4", 101:"5", 102:"6", 103:"7", 104:"8", 105:"9" + } + + var keyIndex = []; + + $items.each(function() { + if ($(this).parent().is(':not(.disabled)')) { + if ($.trim($(this).text().toLowerCase()).substring(0,1) == keyCodeMap[e.keyCode]) { + keyIndex.push($(this).parent().index()); + } + } + }); + + var count = $(document).data('keycount'); + count++; + $(document).data('keycount',count); + + var prevKey = $.trim($(':focus').text().toLowerCase()).substring(0,1); + + if (prevKey != keyCodeMap[e.keyCode]) { + count = 1; + $(document).data('keycount',count); + } else if (count >= keyIndex.length) { + $(document).data('keycount',0); + } + + $items.eq(keyIndex[count - 1]).focus(); + } + + // select focused option if "Enter" or "Spacebar" are pressed + if (/(13|32)/.test(e.keyCode)) { + e.preventDefault(); + $(':focus').click(); + $(document).data('keycount',0); + } + }, + + hide: function() { + this.$newElement.hide(); + }, + + show: function() { + this.$newElement.show(); + }, + + destroy: function() { + this.$newElement.remove(); + this.$element.remove(); + } + }; + + $.fn.selectpicker = function(option, event) { + //get the args of the outer function.. + var args = arguments; + var value; + var chain = this.each(function() { + if ($(this).is('select')) { + var $this = $(this), + data = $this.data('selectpicker'), + options = typeof option == 'object' && option; + + if (!data) { + $this.data('selectpicker', (data = new Selectpicker(this, options, event))); + } else if (options) { + for(var i in options) { + data.options[i] = options[i]; + } + } + + if (typeof option == 'string') { + //Copy the value of option, as once we shift the arguments + //it also shifts the value of option. + var property = option; + if (data[property] instanceof Function) { + [].shift.apply(args); + value = data[property].apply(data, args); + } else { + value = data.options[property]; + } + } + } + }); + + if (value != undefined) { + return value; + } else { + return chain; + } + }; + + $.fn.selectpicker.defaults = { + style: 'btn-default', + size: 'auto', + title: null, + selectedTextFormat : 'values', + noneSelectedText : 'Nothing selected', + countSelectedText: '{0} of {1} selected', + width: false, + container: false, + hideDisabled: false, + showSubtext: false, + showIcon: true, + showContent: true, + dropupAuto: true, + header: false, + liveSearch: false + } + + $(document) + .data('keycount', 0) + .on('keydown', '[data-toggle=dropdown], [role=menu]' , Selectpicker.prototype.keydown) + +}(window.jQuery); diff --git a/templates/admin/default/assets/js/coupon.js b/templates/admin/default/assets/js/coupon.js index 5c52aa097..41e0c1430 100644 --- a/templates/admin/default/assets/js/coupon.js +++ b/templates/admin/default/assets/js/coupon.js @@ -22,17 +22,15 @@ $(function($){ }; // Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX - couponManager.addRuleAjax = function(id) { - console.log('addRuleAjax '+ id); + couponManager.createOrUpdateRuleAjax = function() { + var id = couponManager.ruleToUpdateId; // If create if(!id) { - console.log('pushing'); couponManager.rulesToSave.push(couponManager.ruleToSave); } else { // else update - console.log('editing ' + id); couponManager.rulesToSave[id] = couponManager.ruleToSave; // reset edit mode to off - couponManager.ruleIdToUpdate = false; + couponManager.ruleToUpdateId = false; } // Save @@ -40,57 +38,54 @@ $(function($){ }; // Set rule inputs to allow editing - couponManager.updateRuleAjax = function(id) { - couponManager.ruleToUpdate = couponManager.rulesToSave[id]; - console.log('Set id to edit to ' + id); - couponManager.ruleIdToUpdate = id; - - // Deleting this rule, we will reset it - delete couponManager.rulesToSave[id]; + couponManager.updateRuleSelectAjax = function(id) { + couponManager.ruleToUpdateId = id; + couponManager.ruleToSave = couponManager.rulesToSave[id]; // Set the rule selector $("#category-rule option").filter(function() { - return $(this).val() == couponManager.ruleToUpdate.serviceId; + return $(this).val() == couponManager.ruleToSave.serviceId; }).prop('selected', true); // Force rule input refresh - couponManager.loadRuleInputs(couponManager.ruleToUpdate.serviceId, function() { + couponManager.loadRuleInputs(couponManager.ruleToSave.serviceId, function() { couponManager.fillInRuleInputs(); }); }; // Fill in rule inputs couponManager.fillInRuleInputs = function() { - console.log('fillInRuleInputs with'); - console.log(couponManager.ruleToUpdate); var operatorId = null; var valueId = null; var idName = null; - for (idName in couponManager.ruleToUpdate.operators) { + var id = couponManager.ruleToUpdateId; + if(id) { + couponManager.ruleToSave = couponManager.rulesToSave[id]; + } + + for (idName in couponManager.ruleToSave.operators) { // Setting idName operator select operatorId = idName + '-operator'; - $('#' + operatorId).val(couponManager.ruleToUpdate.operators[idName]); + $('#' + operatorId).val(couponManager.ruleToSave.operators[idName]); - valueId = idName + '-value'; // Setting idName value input - $('#' + valueId).val(couponManager.ruleToUpdate.values[idName]); - } - couponManager.ruleToSave = couponManager.ruleToUpdate; - - var id = couponManager.ruleIdToUpdate; - console.log('id to edit = ' + id); - if(id) { - console.log('setint rulesToSave[' + id + ']'); - console.log(couponManager.ruleToSave); - couponManager.rulesToSave[id] = couponManager.ruleToSave; + valueId = idName + '-value'; + $('#' + valueId).val(couponManager.ruleToSave.values[idName]); } }; // Save rules on click couponManager.onClickSaveRule = function() { $('#constraint-save-btn').on('click', function () { - couponManager.addRuleAjax(couponManager.ruleIdToUpdate); + if($('#category-rule').val() == 'thelia.constraint.rule.available_for_everyone') { + // @todo translate + modal + var r= confirm("Do you really want to set this coupon available to everyone ?"); + if (r == true) { + couponManager.createOrUpdateRuleAjax(); + } + } + }); }; couponManager.onClickSaveRule(); @@ -110,7 +105,7 @@ $(function($){ $('.constraint-update-btn').on('click', function (e) { e.preventDefault(); var $this = $(this); - couponManager.updateRuleAjax($this.attr('data-int')); + couponManager.updateRuleSelectAjax($this.attr('data-int')); // Hide row being updated $this.parent().parent().remove(); @@ -120,6 +115,8 @@ $(function($){ // Reload effect inputs when changing effect couponManager.onEffectChange = function() { + var optionSelected = $("option:selected", this); + $('#effectToolTip').html(optionSelected.attr("data-description")); $('#effect').on('change', function () { var optionSelected = $("option:selected", this); $('#effectToolTip').html(optionSelected.attr("data-description")); @@ -130,7 +127,7 @@ $(function($){ // Reload rule inputs when changing effect couponManager.onRuleChange = function() { $('#category-rule').on('change', function () { - couponManager.loadRuleInputs($(this).val(), function(ruleToSave) {}); + couponManager.loadRuleInputs($(this).val(), function() {}); }); }; couponManager.onRuleChange(); @@ -139,10 +136,37 @@ $(function($){ // var onInputsChange = function() // In AJAX response + // Set max usage to unlimited or not + couponManager.onUsageUnlimitedChange = function() { + if (!$('#max-usage').parent().hasClass('has-error')) { + $('#max-usage').hide().attr('value', '-1'); + $('#max-usage-label').hide(); + } + $('#is-unlimited').change(function(){ + var $this = $(this); + if ($this.is(':checked')) { + $('#max-usage').hide().attr('value', '-1'); + $('#max-usage-label').hide(); + } else { + $('#max-usage').show().val('').attr('value', ''); + $('#max-usage-label').show(); + } + }); + }; + couponManager.onUsageUnlimitedChange(); + }); // Rule to save var couponManager = {}; +// Rule to be saved couponManager.ruleToSave = {}; -couponManager.ruleIdToUpdate = false; \ No newline at end of file +couponManager.ruleToSave.serviceId = false; +couponManager.ruleToSave.operators = {}; +couponManager.ruleToSave.values = {}; +// Rules payload to save +couponManager.rulesToSave = []; +// Rule being updated id +couponManager.ruleToUpdateId = false; + diff --git a/templates/admin/default/assets/js/jqplot/jquery.jqplot.min.js b/templates/admin/default/assets/js/jqplot/jquery.jqplot.min.js new file mode 100644 index 000000000..f25712c36 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/jquery.jqplot.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(L){var u;L.fn.emptyForce=function(){for(var ah=0,ai;(ai=L(this)[ah])!=null;ah++){if(ai.nodeType===1){L.cleanData(ai.getElementsByTagName("*"))}if(L.jqplot.use_excanvas){ai.outerHTML=""}else{while(ai.firstChild){ai.removeChild(ai.firstChild)}}ai=null}return L(this)};L.fn.removeChildForce=function(ah){while(ah.firstChild){this.removeChildForce(ah.firstChild);ah.removeChild(ah.firstChild)}};L.fn.jqplot=function(){var ah=[];var aj=[];for(var ak=0,ai=arguments.length;ak'+ao+"
    ");L("#"+an).addClass("jqplot-error");document.getElementById(an).style.background=L.jqplot.config.errorBackground;document.getElementById(an).style.border=L.jqplot.config.errorBorder;document.getElementById(an).style.fontFamily=L.jqplot.config.errorFontFamily;document.getElementById(an).style.fontSize=L.jqplot.config.errorFontSize;document.getElementById(an).style.fontStyle=L.jqplot.config.errorFontStyle;document.getElementById(an).style.fontWeight=L.jqplot.config.errorFontWeight}}else{am.init(an,aj,ah);am.draw();am.themeEngine.init.call(am);return am}};L.jqplot.version="1.0.8";L.jqplot.revision="1250";L.jqplot.targetCounter=1;L.jqplot.CanvasManager=function(){if(typeof L.jqplot.CanvasManager.canvases=="undefined"){L.jqplot.CanvasManager.canvases=[];L.jqplot.CanvasManager.free=[]}var ah=[];this.getCanvas=function(){var ak;var aj=true;if(!L.jqplot.use_excanvas){for(var al=0,ai=L.jqplot.CanvasManager.canvases.length;al887){L.jqplot.support_canvas_text.result=true}else{L.jqplot.support_canvas_text.result=!!(document.createElement("canvas").getContext&&typeof document.createElement("canvas").getContext("2d").fillText=="function")}}return L.jqplot.support_canvas_text.result};L.jqplot.use_excanvas=((!L.support.boxModel||!L.support.objectAll||!$support.leadingWhitespace)&&!L.jqplot.support_canvas())?true:false;L.jqplot.preInitHooks=[];L.jqplot.postInitHooks=[];L.jqplot.preParseOptionsHooks=[];L.jqplot.postParseOptionsHooks=[];L.jqplot.preDrawHooks=[];L.jqplot.postDrawHooks=[];L.jqplot.preDrawSeriesHooks=[];L.jqplot.postDrawSeriesHooks=[];L.jqplot.preDrawLegendHooks=[];L.jqplot.addLegendRowHooks=[];L.jqplot.preSeriesInitHooks=[];L.jqplot.postSeriesInitHooks=[];L.jqplot.preParseSeriesOptionsHooks=[];L.jqplot.postParseSeriesOptionsHooks=[];L.jqplot.eventListenerHooks=[];L.jqplot.preDrawSeriesShadowHooks=[];L.jqplot.postDrawSeriesShadowHooks=[];L.jqplot.ElemContainer=function(){this._elem;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null}};L.jqplot.ElemContainer.prototype.createElement=function(ak,am,ai,aj,an){this._offsets=am;var ah=ai||"jqplot";var al=document.createElement(ak);this._elem=L(al);this._elem.addClass(ah);this._elem.css(aj);this._elem.attr(an);al=null;return this._elem};L.jqplot.ElemContainer.prototype.getWidth=function(){if(this._elem){return this._elem.outerWidth(true)}else{return null}};L.jqplot.ElemContainer.prototype.getHeight=function(){if(this._elem){return this._elem.outerHeight(true)}else{return null}};L.jqplot.ElemContainer.prototype.getPosition=function(){if(this._elem){return this._elem.position()}else{return{top:null,left:null,bottom:null,right:null}}};L.jqplot.ElemContainer.prototype.getTop=function(){return this.getPosition().top};L.jqplot.ElemContainer.prototype.getLeft=function(){return this.getPosition().left};L.jqplot.ElemContainer.prototype.getBottom=function(){return this._elem.css("bottom")};L.jqplot.ElemContainer.prototype.getRight=function(){return this._elem.css("right")};function w(ah){L.jqplot.ElemContainer.call(this);this.name=ah;this._series=[];this.show=false;this.tickRenderer=L.jqplot.AxisTickRenderer;this.tickOptions={};this.labelRenderer=L.jqplot.AxisLabelRenderer;this.labelOptions={};this.label=null;this.showLabel=true;this.min=null;this.max=null;this.autoscale=false;this.pad=1.2;this.padMax=null;this.padMin=null;this.ticks=[];this.numberTicks;this.tickInterval;this.renderer=L.jqplot.LinearAxisRenderer;this.rendererOptions={};this.showTicks=true;this.showTickMarks=true;this.showMinorTicks=true;this.drawMajorGridlines=true;this.drawMinorGridlines=false;this.drawMajorTickMarks=true;this.drawMinorTickMarks=true;this.useSeriesColor=false;this.borderWidth=null;this.borderColor=null;this.scaleToHiddenSeries=false;this._dataBounds={min:null,max:null};this._intervalStats=[];this._offsets={min:null,max:null};this._ticks=[];this._label=null;this.syncTicks=null;this.tickSpacing=75;this._min=null;this._max=null;this._tickInterval=null;this._numberTicks=null;this.__ticks=null;this._options={}}w.prototype=new L.jqplot.ElemContainer();w.prototype.constructor=w;w.prototype.init=function(){if(L.isFunction(this.renderer)){this.renderer=new this.renderer()}this.tickOptions.axis=this.name;if(this.tickOptions.showMark==null){this.tickOptions.showMark=this.showTicks}if(this.tickOptions.showMark==null){this.tickOptions.showMark=this.showTickMarks}if(this.tickOptions.showLabel==null){this.tickOptions.showLabel=this.showTicks}if(this.label==null||this.label==""){this.showLabel=false}else{this.labelOptions.label=this.label}if(this.showLabel==false){this.labelOptions.show=false}if(this.pad==0){this.pad=1}if(this.padMax==0){this.padMax=1}if(this.padMin==0){this.padMin=1}if(this.padMax==null){this.padMax=(this.pad-1)/2+1}if(this.padMin==null){this.padMin=(this.pad-1)/2+1}this.pad=this.padMax+this.padMin-1;if(this.min!=null||this.max!=null){this.autoscale=false}if(this.syncTicks==null&&this.name.indexOf("y")>-1){this.syncTicks=true}else{if(this.syncTicks==null){this.syncTicks=false}}this.renderer.init.call(this,this.rendererOptions)};w.prototype.draw=function(ah,ai){if(this.__ticks){this.__ticks=null}return this.renderer.draw.call(this,ah,ai)};w.prototype.set=function(){this.renderer.set.call(this)};w.prototype.pack=function(ai,ah){if(this.show){this.renderer.pack.call(this,ai,ah)}if(this._min==null){this._min=this.min;this._max=this.max;this._tickInterval=this.tickInterval;this._numberTicks=this.numberTicks;this.__ticks=this._ticks}};w.prototype.reset=function(){this.renderer.reset.call(this)};w.prototype.resetScale=function(ah){L.extend(true,this,{min:null,max:null,numberTicks:null,tickInterval:null,_ticks:[],ticks:[]},ah);this.resetDataBounds()};w.prototype.resetDataBounds=function(){var ao=this._dataBounds;ao.min=null;ao.max=null;var ai,ap,am;var aj=(this.show)?true:false;for(var al=0;alao.max)||ao.max==null){ao.max=am[ak][0]}}else{if((am[ak][ah]!=null&&am[ak][ah]ao.max)||ao.max==null){ao.max=am[ak][an]}}}if(aj&&ap.renderer.constructor!==L.jqplot.BarRenderer){aj=false}else{if(aj&&this._options.hasOwnProperty("forceTickAt0")&&this._options.forceTickAt0==false){aj=false}else{if(aj&&ap.renderer.constructor===L.jqplot.BarRenderer){if(ap.barDirection=="vertical"&&this.name!="xaxis"&&this.name!="x2axis"){if(this._options.pad!=null||this._options.padMin!=null){aj=false}}else{if(ap.barDirection=="horizontal"&&(this.name=="xaxis"||this.name=="x2axis")){if(this._options.pad!=null||this._options.padMin!=null){aj=false}}}}}}}}if(aj&&this.renderer.constructor===L.jqplot.LinearAxisRenderer&&ao.min>=0){this.padMin=1;this.forceTickAt0=true}};function q(ah){L.jqplot.ElemContainer.call(this);this.show=false;this.location="ne";this.labels=[];this.showLabels=true;this.showSwatches=true;this.placement="insideGrid";this.xoffset=0;this.yoffset=0;this.border;this.background;this.textColor;this.fontFamily;this.fontSize;this.rowSpacing="0.5em";this.renderer=L.jqplot.TableLegendRenderer;this.rendererOptions={};this.preDraw=false;this.marginTop=null;this.marginRight=null;this.marginBottom=null;this.marginLeft=null;this.escapeHtml=false;this._series=[];L.extend(true,this,ah)}q.prototype=new L.jqplot.ElemContainer();q.prototype.constructor=q;q.prototype.setOptions=function(ah){L.extend(true,this,ah);if(this.placement=="inside"){this.placement="insideGrid"}if(this.xoffset>0){if(this.placement=="insideGrid"){switch(this.location){case"nw":case"w":case"sw":if(this.marginLeft==null){this.marginLeft=this.xoffset+"px"}this.marginRight="0px";break;case"ne":case"e":case"se":default:if(this.marginRight==null){this.marginRight=this.xoffset+"px"}this.marginLeft="0px";break}}else{if(this.placement=="outside"){switch(this.location){case"nw":case"w":case"sw":if(this.marginRight==null){this.marginRight=this.xoffset+"px"}this.marginLeft="0px";break;case"ne":case"e":case"se":default:if(this.marginLeft==null){this.marginLeft=this.xoffset+"px"}this.marginRight="0px";break}}}this.xoffset=0}if(this.yoffset>0){if(this.placement=="outside"){switch(this.location){case"sw":case"s":case"se":if(this.marginTop==null){this.marginTop=this.yoffset+"px"}this.marginBottom="0px";break;case"ne":case"n":case"nw":default:if(this.marginBottom==null){this.marginBottom=this.yoffset+"px"}this.marginTop="0px";break}}else{if(this.placement=="insideGrid"){switch(this.location){case"sw":case"s":case"se":if(this.marginBottom==null){this.marginBottom=this.yoffset+"px"}this.marginTop="0px";break;case"ne":case"n":case"nw":default:if(this.marginTop==null){this.marginTop=this.yoffset+"px"}this.marginBottom="0px";break}}}this.yoffset=0}};q.prototype.init=function(){if(L.isFunction(this.renderer)){this.renderer=new this.renderer()}this.renderer.init.call(this,this.rendererOptions)};q.prototype.draw=function(ai,aj){for(var ah=0;ah');this.target.append(az);az.height(aD);az.width(aA);az.css("top",this.eventCanvas._offsets.top);az.css("left",this.eventCanvas._offsets.left);var aC=L('
    ');az.append(aC);aC.html(this.noDataIndicator.indicator);var aB=aC.height();var ax=aC.width();aC.height(aB);aC.width(ax);aC.css("top",(aD-aB)/2+"px")})}}this.data=L.extend(true,[],ar);this.parseOptions(ay);if(this.textColor){this.target.css("color",this.textColor)}if(this.fontFamily){this.target.css("font-family",this.fontFamily)}if(this.fontSize){this.target.css("font-size",this.fontSize)}this.title.init();this.legend.init();this._sumy=0;this._sumx=0;this.computePlotData();for(var at=0;at0){for(var aq=au;aq--;){var an=this._plotData[aq][ap][av];if(aw*an>=0){this._plotData[au][ap][av]+=an;this._stackData[au][ap][av]+=an;break}}}}}else{for(var ar=0;ar0){at._prevPlotData=this.series[au-1]._plotData}at._sumy=0;at._sumx=0;for(ar=at.data.length-1;ar>-1;ar--){at._sumy+=at.data[ar][1];at._sumx+=at.data[ar][0]}}};this.populatePlotData=function(au,av){this._plotData=[];this._stackData=[];au._stackData=[];au._plotData=[];var ay={x:[],y:[]};if(this.stackSeries&&!au.disableStack){au._stack=true;var ax=(au._stackAxis==="x")?0:1;var az=L.extend(true,[],au.data);var aA=L.extend(true,[],au.data);var an,am,ao,aw,al;for(var ar=0;ar=0){aA[aq][ax]+=aw}}}for(var at=0;at0){au._prevPlotData=this.series[av-1]._plotData}au._sumy=0;au._sumx=0;for(at=au.data.length-1;at>-1;at--){au._sumy+=au.data[at][1];au._sumx+=au.data[at][0]}};this.getNextSeriesColor=(function(am){var al=0;var an=am.seriesColors;return function(){if(al=0&&an>=0){al.top+=aK;al.bottom+=aK;al.left+=an;al.right+=an}}var am=["top","bottom","left","right"];for(var aB in am){if(this._gridPadding[am[aB]]==null&&al[am[aB]]>0){this._gridPadding[am[aB]]=al[am[aB]]}else{if(this._gridPadding[am[aB]]==null){this._gridPadding[am[aB]]=this._defaultGridPadding[am[aB]]}}}var aA=this._gridPadding;if(this.legend.placement==="outsideGrid"){aA={top:this.title.getHeight(),left:0,right:0,bottom:0};if(this.legend.location==="s"){aA.left=this._gridPadding.left;aA.right=this._gridPadding.right}}ar.xaxis.pack({position:"absolute",bottom:this._gridPadding.bottom-ar.xaxis.getHeight(),left:0,width:this._width},{min:this._gridPadding.left,max:this._width-this._gridPadding.right});ar.yaxis.pack({position:"absolute",top:0,left:this._gridPadding.left-ar.yaxis.getWidth(),height:this._height},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top});ar.x2axis.pack({position:"absolute",top:this._gridPadding.top-ar.x2axis.getHeight(),left:0,width:this._width},{min:this._gridPadding.left,max:this._width-this._gridPadding.right});for(aH=8;aH>0;aH--){ar[aG[aH-1]].pack({position:"absolute",top:0,right:this._gridPadding.right-az[aH-1]},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top})}var au=(this._width-this._gridPadding.left-this._gridPadding.right)/2+this._gridPadding.left-ar.yMidAxis.getWidth()/2;ar.yMidAxis.pack({position:"absolute",top:0,left:au,zIndex:9,textAlign:"center"},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top});this.target.append(this.grid.createElement(this._gridPadding,this));this.grid.draw();var aq=this.series;var aJ=aq.length;for(aH=0,aE=aJ;aHax)?av:ax;var ar=this.series[aw];var aq=this.series[au];if(aq.renderer.smooth){var ap=aq.renderer._smoothedData.slice(0).reverse()}else{var ap=aq.gridData.slice(0).reverse()}if(ar.renderer.smooth){var at=ar.renderer._smoothedData.concat(ap)}else{var at=ar.gridData.concat(ap)}var ao=(an.color!==null)?an.color:this.series[ax].fillColor;var ay=(an.baseSeries!==null)?an.baseSeries:aw;var am=this.series[ay].renderer.shapeRenderer;var al={fillStyle:ao,fill:true,closePath:true};am.draw(ar.shadowCanvas._ctx,at,al)};this.bindCustomEvents=function(){this.eventCanvas._elem.bind("click",{plot:this},this.onClick);this.eventCanvas._elem.bind("dblclick",{plot:this},this.onDblClick);this.eventCanvas._elem.bind("mousedown",{plot:this},this.onMouseDown);this.eventCanvas._elem.bind("mousemove",{plot:this},this.onMouseMove);this.eventCanvas._elem.bind("mouseenter",{plot:this},this.onMouseEnter);this.eventCanvas._elem.bind("mouseleave",{plot:this},this.onMouseLeave);if(this.captureRightClick){this.eventCanvas._elem.bind("mouseup",{plot:this},this.onRightClick);this.eventCanvas._elem.get(0).oncontextmenu=function(){return false}}else{this.eventCanvas._elem.bind("mouseup",{plot:this},this.onMouseUp)}};function ai(av){var au=av.data.plot;var ap=au.eventCanvas._elem.offset();var at={x:av.pageX-ap.left,y:av.pageY-ap.top};var aq={xaxis:null,yaxis:null,x2axis:null,y2axis:null,y3axis:null,y4axis:null,y5axis:null,y6axis:null,y7axis:null,y8axis:null,y9axis:null,yMidAxis:null};var ar=["xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis","yMidAxis"];var al=au.axes;var am,ao;for(am=11;am>0;am--){ao=ar[am-1];if(al[ao].show){aq[ao]=al[ao].series_p2u(at[ao.charAt(0)])}}return{offsets:ap,gridPos:at,dataPos:aq}}function ak(al,am){var aq=am.series;var aW,aU,aT,aO,aP,aJ,aI,aw,au,az,aA,aK;var aS,aX,aQ,ar,aH,aM,aV;var an,aN;for(aT=am.seriesStack.length-1;aT>=0;aT--){aW=am.seriesStack[aT];aO=aq[aW];aV=aO._highlightThreshold;switch(aO.renderer.constructor){case L.jqplot.BarRenderer:aJ=al.x;aI=al.y;for(aU=0;aUaH[0][0]&&aJaH[2][1]&&aIaH[0][0]+aV[0][0]&&aJaH[2][1]&&aI0&&-aI>=0){aw=2*Math.PI-Math.atan(-aI/aJ)}else{if(aJ>0&&-aI<0){aw=-Math.atan(-aI/aJ)}else{if(aJ<0){aw=Math.PI-Math.atan(-aI/aJ)}else{if(aJ==0&&-aI>0){aw=3*Math.PI/2}else{if(aJ==0&&-aI<0){aw=Math.PI/2}else{if(aJ==0&&aI==0){aw=0}}}}}}if(az){aw-=az;if(aw<0){aw+=2*Math.PI}else{if(aw>2*Math.PI){aw-=2*Math.PI}}}au=aO.sliceMargin/180*Math.PI;if(aPaO._innerRadius){for(aU=0;aU0)?aO.gridData[aU-1][1]+au:au;aK=aO.gridData[aU][1];if(aw>aA&&aw0&&-aI>=0){aw=2*Math.PI-Math.atan(-aI/aJ)}else{if(aJ>0&&-aI<0){aw=-Math.atan(-aI/aJ)}else{if(aJ<0){aw=Math.PI-Math.atan(-aI/aJ)}else{if(aJ==0&&-aI>0){aw=3*Math.PI/2}else{if(aJ==0&&-aI<0){aw=Math.PI/2}else{if(aJ==0&&aI==0){aw=0}}}}}}if(az){aw-=az;if(aw<0){aw+=2*Math.PI}else{if(aw>2*Math.PI){aw-=2*Math.PI}}}au=aO.sliceMargin/180*Math.PI;if(aP0)?aO.gridData[aU-1][1]+au:au;aK=aO.gridData[aU][1];if(aw>aA&&aw=ay[0][1]&&aI<=ay[3][1]&&aJ>=at[0]&&aJ<=aE[0]){return{seriesIndex:aO.index,pointIndex:aU,gridData:null,data:aO.data[aU]}}}break;case L.jqplot.LineRenderer:aJ=al.x;aI=al.y;aP=aO.renderer;if(aO.show){if((aO.fill||(aO.renderer.bands.show&&aO.renderer.bands.fill))&&(!am.plugins.highlighter||!am.plugins.highlighter.show)){var ax=false;if(aJ>aO._boundingBox[0][0]&&aJaO._boundingBox[1][1]&&aI=aI||aB[1]=aI){if(aC[0]+(aI-aC[1])/(aB[1]-aC[1])*(aB[0]-aC[0])0)?aN:0;for(var aU=0;aU=aQ[0]-aP._bodyWidth/2&&aJ<=aQ[0]+aP._bodyWidth/2&&aI>=av(aO.data[aU][2])&&aI<=av(aO.data[aU][3])){return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}else{if(!aP.hlc){var av=aO._yaxis.series_u2p;if(aJ>=aQ[0]-aP._tickLength&&aJ<=aQ[0]+aP._tickLength&&aI>=av(aO.data[aU][2])&&aI<=av(aO.data[aU][3])){return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}else{var av=aO._yaxis.series_u2p;if(aJ>=aQ[0]-aP._tickLength&&aJ<=aQ[0]+aP._tickLength&&aI>=av(aO.data[aU][1])&&aI<=av(aO.data[aU][2])){return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}}}else{if(aQ[0]!=null&&aQ[1]!=null){aX=Math.sqrt((aJ-aQ[0])*(aJ-aQ[0])+(aI-aQ[1])*(aI-aQ[1]));if(aX<=an&&(aX<=aS||aS==null)){aS=aX;return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}}}}}break;default:aJ=al.x;aI=al.y;aP=aO.renderer;if(aO.show){aN=aO.markerRenderer.size/2+aO.neighborThreshold;an=(aN>0)?aN:0;for(var aU=0;aU=aQ[0]-aP._bodyWidth/2&&aJ<=aQ[0]+aP._bodyWidth/2&&aI>=av(aO.data[aU][2])&&aI<=av(aO.data[aU][3])){return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}else{if(!aP.hlc){var av=aO._yaxis.series_u2p;if(aJ>=aQ[0]-aP._tickLength&&aJ<=aQ[0]+aP._tickLength&&aI>=av(aO.data[aU][2])&&aI<=av(aO.data[aU][3])){return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}else{var av=aO._yaxis.series_u2p;if(aJ>=aQ[0]-aP._tickLength&&aJ<=aQ[0]+aP._tickLength&&aI>=av(aO.data[aU][1])&&aI<=av(aO.data[aU][2])){return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}}}else{aX=Math.sqrt((aJ-aQ[0])*(aJ-aQ[0])+(aI-aQ[1])*(aI-aQ[1]));if(aX<=an&&(aX<=aS||aS==null)){aS=aX;return{seriesIndex:aW,pointIndex:aU,gridData:aQ,data:aO.data[aU]}}}}}break}}return null}this.onClick=function(an){var am=ai(an);var ap=an.data.plot;var ao=ak(am.gridPos,ap);var al=L.Event("jqplotClick");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,ao,ap])};this.onDblClick=function(an){var am=ai(an);var ap=an.data.plot;var ao=ak(am.gridPos,ap);var al=L.Event("jqplotDblClick");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,ao,ap])};this.onMouseDown=function(an){var am=ai(an);var ap=an.data.plot;var ao=ak(am.gridPos,ap);var al=L.Event("jqplotMouseDown");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,ao,ap])};this.onMouseUp=function(an){var am=ai(an);var al=L.Event("jqplotMouseUp");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,null,an.data.plot])};this.onRightClick=function(an){var am=ai(an);var ap=an.data.plot;var ao=ak(am.gridPos,ap);if(ap.captureRightClick){if(an.which==3){var al=L.Event("jqplotRightClick");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,ao,ap])}else{var al=L.Event("jqplotMouseUp");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,ao,ap])}}};this.onMouseMove=function(an){var am=ai(an);var ap=an.data.plot;var ao=ak(am.gridPos,ap);var al=L.Event("jqplotMouseMove");al.pageX=an.pageX;al.pageY=an.pageY;L(this).trigger(al,[am.gridPos,am.dataPos,ao,ap])};this.onMouseEnter=function(an){var am=ai(an);var ao=an.data.plot;var al=L.Event("jqplotMouseEnter");al.pageX=an.pageX;al.pageY=an.pageY;al.relatedTarget=an.relatedTarget;L(this).trigger(al,[am.gridPos,am.dataPos,null,ao])};this.onMouseLeave=function(an){var am=ai(an);var ao=an.data.plot;var al=L.Event("jqplotMouseLeave");al.pageX=an.pageX;al.pageY=an.pageY;al.relatedTarget=an.relatedTarget;L(this).trigger(al,[am.gridPos,am.dataPos,null,ao])};this.drawSeries=function(an,al){var ap,ao,am;al=(typeof(an)==="number"&&al==null)?an:al;an=(typeof(an)==="object")?an:{};if(al!=u){ao=this.series[al];am=ao.shadowCanvas._ctx;am.clearRect(0,0,am.canvas.width,am.canvas.height);ao.drawShadow(am,an,this);am=ao.canvas._ctx;am.clearRect(0,0,am.canvas.width,am.canvas.height);ao.draw(am,an,this);if(ao.renderer.constructor==L.jqplot.BezierCurveRenderer){if(al660)?ah[aj]*0.85:0.73*ah[aj]+90;ah[aj]=parseInt(ah[aj],10);(ah[aj]>255)?255:ah[aj]}ah[3]=0.3+0.35*al[3];ak.push("rgba("+ah[0]+","+ah[1]+","+ah[2]+","+ah[3]+")")}}else{var al=L.jqplot.getColorComponents(ai);var ah=[al[0],al[1],al[2]];var an=ah[0]+ah[1]+ah[2];for(var aj=0;aj<3;aj++){ah[aj]=(an>660)?ah[aj]*0.85:0.73*ah[aj]+90;ah[aj]=parseInt(ah[aj],10);(ah[aj]>255)?255:ah[aj]}ah[3]=0.3+0.35*al[3];ak="rgba("+ah[0]+","+ah[1]+","+ah[2]+","+ah[3]+")"}return ak};L.jqplot.ColorGenerator=function(ai){ai=ai||L.jqplot.config.defaultColors;var ah=0;this.next=function(){if(ah0){return ai[ah--]}else{ah=ai.length-1;return ai[ah]}};this.get=function(ak){var aj=ak-ai.length*Math.floor(ak/ai.length);return ai[aj]};this.setColors=function(aj){ai=aj};this.reset=function(){ah=0};this.getIndex=function(){return ah};this.setIndex=function(aj){ah=aj}};L.jqplot.hex2rgb=function(aj,ah){aj=aj.replace("#","");if(aj.length==3){aj=aj.charAt(0)+aj.charAt(0)+aj.charAt(1)+aj.charAt(1)+aj.charAt(2)+aj.charAt(2)}var ai;ai="rgba("+parseInt(aj.slice(0,2),16)+", "+parseInt(aj.slice(2,4),16)+", "+parseInt(aj.slice(4,6),16);if(ah){ai+=", "+ah}ai+=")";return ai};L.jqplot.rgb2hex=function(am){var aj=/rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *(?:, *[0-9.]*)?\)/;var ah=am.match(aj);var al="#";for(var ak=1;ak<4;ak++){var ai;if(ah[ak].search(/%/)!=-1){ai=parseInt(255*ah[ak]/100,10).toString(16);if(ai.length==1){ai="0"+ai}}else{ai=parseInt(ah[ak],10).toString(16);if(ai.length==1){ai="0"+ai}}al+=ai}return al};L.jqplot.normalize2rgb=function(ai,ah){if(ai.search(/^ *rgba?\(/)!=-1){return ai}else{if(ai.search(/^ *#?[0-9a-fA-F]?[0-9a-fA-F]/)!=-1){return L.jqplot.hex2rgb(ai,ah)}else{throw new Error("Invalid color spec")}}};L.jqplot.getColorComponents=function(am){am=L.jqplot.colorKeywordMap[am]||am;var ak=L.jqplot.normalize2rgb(am);var aj=/rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *,? *([0-9.]* *)?\)/;var ah=ak.match(aj);var ai=[];for(var al=1;al<4;al++){if(ah[al].search(/%/)!=-1){ai[al-1]=parseInt(255*ah[al]/100,10)}else{ai[al-1]=parseInt(ah[al],10)}}ai[3]=parseFloat(ah[4])?parseFloat(ah[4]):1;return ai};L.jqplot.colorKeywordMap={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",aqua:"rgb( 0, 255, 255)",aquamarine:"rgb(127, 255, 212)",azure:"rgb(240, 255, 255)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",black:"rgb( 0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb( 0, 0, 255)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",burlywood:"rgb(222, 184, 135)",cadetblue:"rgb( 95, 158, 160)",chartreuse:"rgb(127, 255, 0)",chocolate:"rgb(210, 105, 30)",coral:"rgb(255, 127, 80)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",crimson:"rgb(220, 20, 60)",cyan:"rgb( 0, 255, 255)",darkblue:"rgb( 0, 0, 139)",darkcyan:"rgb( 0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgray:"rgb(169, 169, 169)",darkgreen:"rgb( 0, 100, 0)",darkgrey:"rgb(169, 169, 169)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb( 85, 107, 47)",darkorange:"rgb(255, 140, 0)",darkorchid:"rgb(153, 50, 204)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkslateblue:"rgb( 72, 61, 139)",darkslategray:"rgb( 47, 79, 79)",darkslategrey:"rgb( 47, 79, 79)",darkturquoise:"rgb( 0, 206, 209)",darkviolet:"rgb(148, 0, 211)",deeppink:"rgb(255, 20, 147)",deepskyblue:"rgb( 0, 191, 255)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb( 30, 144, 255)",firebrick:"rgb(178, 34, 34)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb( 34, 139, 34)",fuchsia:"rgb(255, 0, 255)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",goldenrod:"rgb(218, 165, 32)",gray:"rgb(128, 128, 128)",grey:"rgb(128, 128, 128)",green:"rgb( 0, 128, 0)",greenyellow:"rgb(173, 255, 47)",honeydew:"rgb(240, 255, 240)",hotpink:"rgb(255, 105, 180)",indianred:"rgb(205, 92, 92)",indigo:"rgb( 75, 0, 130)",ivory:"rgb(255, 255, 240)",khaki:"rgb(240, 230, 140)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lightblue:"rgb(173, 216, 230)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgray:"rgb(211, 211, 211)",lightgreen:"rgb(144, 238, 144)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightsalmon:"rgb(255, 160, 122)",lightseagreen:"rgb( 32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightyellow:"rgb(255, 255, 224)",lime:"rgb( 0, 255, 0)",limegreen:"rgb( 50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",maroon:"rgb(128, 0, 0)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb( 0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumpurple:"rgb(147, 112, 219)",mediumseagreen:"rgb( 60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb( 0, 250, 154)",mediumturquoise:"rgb( 72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb( 25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navy:"rgb( 0, 0, 128)",oldlace:"rgb(253, 245, 230)",olive:"rgb(128, 128, 0)",olivedrab:"rgb(107, 142, 35)",orange:"rgb(255, 165, 0)",orangered:"rgb(255, 69, 0)",orchid:"rgb(218, 112, 214)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",paleturquoise:"rgb(175, 238, 238)",palevioletred:"rgb(219, 112, 147)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",plum:"rgb(221, 160, 221)",powderblue:"rgb(176, 224, 230)",purple:"rgb(128, 0, 128)",red:"rgb(255, 0, 0)",rosybrown:"rgb(188, 143, 143)",royalblue:"rgb( 65, 105, 225)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb( 46, 139, 87)",seashell:"rgb(255, 245, 238)",sienna:"rgb(160, 82, 45)",silver:"rgb(192, 192, 192)",skyblue:"rgb(135, 206, 235)",slateblue:"rgb(106, 90, 205)",slategray:"rgb(112, 128, 144)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",springgreen:"rgb( 0, 255, 127)",steelblue:"rgb( 70, 130, 180)",tan:"rgb(210, 180, 140)",teal:"rgb( 0, 128, 128)",thistle:"rgb(216, 191, 216)",tomato:"rgb(255, 99, 71)",turquoise:"rgb( 64, 224, 208)",violet:"rgb(238, 130, 238)",wheat:"rgb(245, 222, 179)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellowgreen:"rgb(154, 205, 50)"};L.jqplot.AxisLabelRenderer=function(ah){L.jqplot.ElemContainer.call(this);this.axis;this.show=true;this.label="";this.fontFamily=null;this.fontSize=null;this.textColor=null;this._elem;this.escapeHTML=false;L.extend(true,this,ah)};L.jqplot.AxisLabelRenderer.prototype=new L.jqplot.ElemContainer();L.jqplot.AxisLabelRenderer.prototype.constructor=L.jqplot.AxisLabelRenderer;L.jqplot.AxisLabelRenderer.prototype.init=function(ah){L.extend(true,this,ah)};L.jqplot.AxisLabelRenderer.prototype.draw=function(ah,ai){if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=L('
    ');if(Number(this.label)){this._elem.css("white-space","nowrap")}if(!this.escapeHTML){this._elem.html(this.label)}else{this._elem.text(this.label)}if(this.fontFamily){this._elem.css("font-family",this.fontFamily)}if(this.fontSize){this._elem.css("font-size",this.fontSize)}if(this.textColor){this._elem.css("color",this.textColor)}return this._elem};L.jqplot.AxisLabelRenderer.prototype.pack=function(){};L.jqplot.AxisTickRenderer=function(ah){L.jqplot.ElemContainer.call(this);this.mark="outside";this.axis;this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.size=4;this.markSize=6;this.show=true;this.showLabel=true;this.label=null;this.value=null;this._styles={};this.formatter=L.jqplot.DefaultTickFormatter;this.prefix="";this.suffix="";this.formatString="";this.fontFamily;this.fontSize;this.textColor;this.escapeHTML=false;this._elem;this._breakTick=false;L.extend(true,this,ah)};L.jqplot.AxisTickRenderer.prototype.init=function(ah){L.extend(true,this,ah)};L.jqplot.AxisTickRenderer.prototype=new L.jqplot.ElemContainer();L.jqplot.AxisTickRenderer.prototype.constructor=L.jqplot.AxisTickRenderer;L.jqplot.AxisTickRenderer.prototype.setTick=function(ah,aj,ai){this.value=ah;this.axis=aj;if(ai){this.isMinorTick=true}return this};L.jqplot.AxisTickRenderer.prototype.draw=function(){if(this.label===null){this.label=this.prefix+this.formatter(this.formatString,this.value)+this.suffix}var ai={position:"absolute"};if(Number(this.label)){ai.whitSpace="nowrap"}if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=L(document.createElement("div"));this._elem.addClass("jqplot-"+this.axis+"-tick");if(!this.escapeHTML){this._elem.html(this.label)}else{this._elem.text(this.label)}this._elem.css(ai);for(var ah in this._styles){this._elem.css(ah,this._styles[ah])}if(this.fontFamily){this._elem.css("font-family",this.fontFamily)}if(this.fontSize){this._elem.css("font-size",this.fontSize)}if(this.textColor){this._elem.css("color",this.textColor)}if(this._breakTick){this._elem.addClass("jqplot-breakTick")}return this._elem};L.jqplot.DefaultTickFormatter=function(ah,ai){if(typeof ai=="number"){if(!ah){ah=L.jqplot.config.defaultTickFormatString}return L.jqplot.sprintf(ah,ai)}else{return String(ai)}};L.jqplot.PercentTickFormatter=function(ah,ai){if(typeof ai=="number"){ai=100*ai;if(!ah){ah=L.jqplot.config.defaultTickFormatString}return L.jqplot.sprintf(ah,ai)}else{return String(ai)}};L.jqplot.AxisTickRenderer.prototype.pack=function(){};L.jqplot.CanvasGridRenderer=function(){this.shadowRenderer=new L.jqplot.ShadowRenderer()};L.jqplot.CanvasGridRenderer.prototype.init=function(ai){this._ctx;L.extend(true,this,ai);var ah={lineJoin:"miter",lineCap:"round",fill:false,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.shadowWidth,closePath:false,strokeStyle:this.shadowColor};this.renderer.shadowRenderer.init(ah)};L.jqplot.CanvasGridRenderer.prototype.createElement=function(ak){var aj;if(this._elem){if(L.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==u){aj=this._elem.get(0);window.G_vmlCanvasManager.uninitElement(aj);aj=null}this._elem.emptyForce();this._elem=null}aj=ak.canvasManager.getCanvas();var ah=this._plotDimensions.width;var ai=this._plotDimensions.height;aj.width=ah;aj.height=ai;this._elem=L(aj);this._elem.addClass("jqplot-grid-canvas");this._elem.css({position:"absolute",left:0,top:0});aj=ak.canvasManager.initCanvas(aj);this._top=this._offsets.top;this._bottom=ai-this._offsets.bottom;this._left=this._offsets.left;this._right=ah-this._offsets.right;this._width=this._right-this._left;this._height=this._bottom-this._top;aj=null;return this._elem};L.jqplot.CanvasGridRenderer.prototype.draw=function(){this._ctx=this._elem.get(0).getContext("2d");var at=this._ctx;var aw=this._axes;at.save();at.clearRect(0,0,this._plotDimensions.width,this._plotDimensions.height);at.fillStyle=this.backgroundColor||this.background;at.fillRect(this._left,this._top,this._width,this._height);at.save();at.lineJoin="miter";at.lineCap="butt";at.lineWidth=this.gridLineWidth;at.strokeStyle=this.gridLineColor;var aA,az,ap,aq;var am=["xaxis","yaxis","x2axis","y2axis"];for(var ay=4;ay>0;ay--){var aD=am[ay-1];var ah=aw[aD];var aB=ah._ticks;var ar=aB.length;if(ah.show){if(ah.drawBaseline){var aC={};if(ah.baselineWidth!==null){aC.lineWidth=ah.baselineWidth}if(ah.baselineColor!==null){aC.strokeStyle=ah.baselineColor}switch(aD){case"xaxis":ao(this._left,this._bottom,this._right,this._bottom,aC);break;case"yaxis":ao(this._left,this._bottom,this._left,this._top,aC);break;case"x2axis":ao(this._left,this._bottom,this._right,this._bottom,aC);break;case"y2axis":ao(this._right,this._bottom,this._right,this._top,aC);break}}for(var au=ar;au>0;au--){var an=aB[au-1];if(an.show){var ak=Math.round(ah.u2p(an.value))+0.5;switch(aD){case"xaxis":if(an.showGridline&&this.drawGridlines&&((!an.isMinorTick&&ah.drawMajorGridlines)||(an.isMinorTick&&ah.drawMinorGridlines))){ao(ak,this._top,ak,this._bottom)}if(an.showMark&&an.mark&&((!an.isMinorTick&&ah.drawMajorTickMarks)||(an.isMinorTick&&ah.drawMinorTickMarks))){ap=an.markSize;aq=an.mark;var ak=Math.round(ah.u2p(an.value))+0.5;switch(aq){case"outside":aA=this._bottom;az=this._bottom+ap;break;case"inside":aA=this._bottom-ap;az=this._bottom;break;case"cross":aA=this._bottom-ap;az=this._bottom+ap;break;default:aA=this._bottom;az=this._bottom+ap;break}if(this.shadow){this.renderer.shadowRenderer.draw(at,[[ak,aA],[ak,az]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}ao(ak,aA,ak,az)}break;case"yaxis":if(an.showGridline&&this.drawGridlines&&((!an.isMinorTick&&ah.drawMajorGridlines)||(an.isMinorTick&&ah.drawMinorGridlines))){ao(this._right,ak,this._left,ak)}if(an.showMark&&an.mark&&((!an.isMinorTick&&ah.drawMajorTickMarks)||(an.isMinorTick&&ah.drawMinorTickMarks))){ap=an.markSize;aq=an.mark;var ak=Math.round(ah.u2p(an.value))+0.5;switch(aq){case"outside":aA=this._left-ap;az=this._left;break;case"inside":aA=this._left;az=this._left+ap;break;case"cross":aA=this._left-ap;az=this._left+ap;break;default:aA=this._left-ap;az=this._left;break}if(this.shadow){this.renderer.shadowRenderer.draw(at,[[aA,ak],[az,ak]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}ao(aA,ak,az,ak,{strokeStyle:ah.borderColor})}break;case"x2axis":if(an.showGridline&&this.drawGridlines&&((!an.isMinorTick&&ah.drawMajorGridlines)||(an.isMinorTick&&ah.drawMinorGridlines))){ao(ak,this._bottom,ak,this._top)}if(an.showMark&&an.mark&&((!an.isMinorTick&&ah.drawMajorTickMarks)||(an.isMinorTick&&ah.drawMinorTickMarks))){ap=an.markSize;aq=an.mark;var ak=Math.round(ah.u2p(an.value))+0.5;switch(aq){case"outside":aA=this._top-ap;az=this._top;break;case"inside":aA=this._top;az=this._top+ap;break;case"cross":aA=this._top-ap;az=this._top+ap;break;default:aA=this._top-ap;az=this._top;break}if(this.shadow){this.renderer.shadowRenderer.draw(at,[[ak,aA],[ak,az]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}ao(ak,aA,ak,az)}break;case"y2axis":if(an.showGridline&&this.drawGridlines&&((!an.isMinorTick&&ah.drawMajorGridlines)||(an.isMinorTick&&ah.drawMinorGridlines))){ao(this._left,ak,this._right,ak)}if(an.showMark&&an.mark&&((!an.isMinorTick&&ah.drawMajorTickMarks)||(an.isMinorTick&&ah.drawMinorTickMarks))){ap=an.markSize;aq=an.mark;var ak=Math.round(ah.u2p(an.value))+0.5;switch(aq){case"outside":aA=this._right;az=this._right+ap;break;case"inside":aA=this._right-ap;az=this._right;break;case"cross":aA=this._right-ap;az=this._right+ap;break;default:aA=this._right;az=this._right+ap;break}if(this.shadow){this.renderer.shadowRenderer.draw(at,[[aA,ak],[az,ak]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}ao(aA,ak,az,ak,{strokeStyle:ah.borderColor})}break;default:break}}}an=null}ah=null;aB=null}am=["y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis","yMidAxis"];for(var ay=7;ay>0;ay--){var ah=aw[am[ay-1]];var aB=ah._ticks;if(ah.show){var ai=aB[ah.numberTicks-1];var al=aB[0];var aj=ah.getLeft();var av=[[aj,ai.getTop()+ai.getHeight()/2],[aj,al.getTop()+al.getHeight()/2+1]];if(this.shadow){this.renderer.shadowRenderer.draw(at,av,{lineCap:"butt",fill:false,closePath:false})}ao(av[0][0],av[0][1],av[1][0],av[1][1],{lineCap:"butt",strokeStyle:ah.borderColor,lineWidth:ah.borderWidth});for(var au=aB.length;au>0;au--){var an=aB[au-1];ap=an.markSize;aq=an.mark;var ak=Math.round(ah.u2p(an.value))+0.5;if(an.showMark&&an.mark){switch(aq){case"outside":aA=aj;az=aj+ap;break;case"inside":aA=aj-ap;az=aj;break;case"cross":aA=aj-ap;az=aj+ap;break;default:aA=aj;az=aj+ap;break}av=[[aA,ak],[az,ak]];if(this.shadow){this.renderer.shadowRenderer.draw(at,av,{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}ao(aA,ak,az,ak,{strokeStyle:ah.borderColor})}an=null}al=null}ah=null;aB=null}at.restore();function ao(aH,aG,aE,ax,aF){at.save();aF=aF||{};if(aF.lineWidth==null||aF.lineWidth!=0){L.extend(true,at,aF);at.beginPath();at.moveTo(aH,aG);at.lineTo(aE,ax);at.stroke();at.restore()}}if(this.shadow){var av=[[this._left,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(at,av)}if(this.borderWidth!=0&&this.drawBorder){ao(this._left,this._top,this._right,this._top,{lineCap:"round",strokeStyle:aw.x2axis.borderColor,lineWidth:aw.x2axis.borderWidth});ao(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:aw.y2axis.borderColor,lineWidth:aw.y2axis.borderWidth});ao(this._right,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:aw.xaxis.borderColor,lineWidth:aw.xaxis.borderWidth});ao(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:aw.yaxis.borderColor,lineWidth:aw.yaxis.borderWidth})}at.restore();at=null;aw=null};L.jqplot.DivTitleRenderer=function(){};L.jqplot.DivTitleRenderer.prototype.init=function(ah){L.extend(true,this,ah)};L.jqplot.DivTitleRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}var ak=this.renderer;var aj=document.createElement("div");this._elem=L(aj);this._elem.addClass("jqplot-title");if(!this.text){this.show=false;this._elem.height(0);this._elem.width(0)}else{if(this.text){var ah;if(this.color){ah=this.color}else{if(this.textColor){ah=this.textColor}}var ai={position:"absolute",top:"0px",left:"0px"};if(this._plotWidth){ai.width=this._plotWidth+"px"}if(this.fontSize){ai.fontSize=this.fontSize}if(typeof this.textAlign==="string"){ai.textAlign=this.textAlign}else{ai.textAlign="center"}if(ah){ai.color=ah}if(this.paddingBottom){ai.paddingBottom=this.paddingBottom}if(this.fontFamily){ai.fontFamily=this.fontFamily}this._elem.css(ai);if(this.escapeHtml){this._elem.text(this.text)}else{this._elem.html(this.text)}}}aj=null;return this._elem};L.jqplot.DivTitleRenderer.prototype.pack=function(){};var r=0.1;L.jqplot.LinePattern=function(aw,aq){var ap={dotted:[r,L.jqplot.config.dotGapLength],dashed:[L.jqplot.config.dashLength,L.jqplot.config.gapLength],solid:null};if(typeof aq==="string"){if(aq[0]==="."||aq[0]==="-"){var ax=aq;aq=[];for(var ao=0,al=ax.length;ao0)&&(aC>0)){aA/=aB;az/=aB;while(true){var aD=aC*ar;if(aD=aq.length){ak=0}ar=aq[ak]}else{au=ay;at=aE;if((ak&1)==0){aw.lineTo(au,at)}else{aw.moveTo(au,at)}ar-=aB/aC;break}}}};var ai=function(){aw.beginPath()};var am=function(){aj(an,ah)};return{moveTo:av,lineTo:aj,beginPath:ai,closePath:am}};L.jqplot.LineRenderer=function(){this.shapeRenderer=new L.jqplot.ShapeRenderer();this.shadowRenderer=new L.jqplot.ShadowRenderer()};L.jqplot.LineRenderer.prototype.init=function(ai,an){ai=ai||{};this._type="line";this.renderer.animation={show:false,direction:"left",speed:2500,_supported:true};this.renderer.smooth=false;this.renderer.tension=null;this.renderer.constrainSmoothing=true;this.renderer._smoothedData=[];this.renderer._smoothedPlotData=[];this.renderer._hiBandGridData=[];this.renderer._lowBandGridData=[];this.renderer._hiBandSmoothedData=[];this.renderer._lowBandSmoothedData=[];this.renderer.bandData=[];this.renderer.bands={show:false,hiData:[],lowData:[],color:this.color,showLines:false,fill:true,fillColor:null,_min:null,_max:null,interval:"3%"};var al={highlightMouseOver:ai.highlightMouseOver,highlightMouseDown:ai.highlightMouseDown,highlightColor:ai.highlightColor};delete (ai.highlightMouseOver);delete (ai.highlightMouseDown);delete (ai.highlightColor);L.extend(true,this.renderer,ai);this.renderer.options=ai;if(this.renderer.bandData.length>1&&(!ai.bands||ai.bands.show==null)){this.renderer.bands.show=true}else{if(ai.bands&&ai.bands.show==null&&ai.bands.interval!=null){this.renderer.bands.show=true}}if(this.fill){this.renderer.bands.show=false}if(this.renderer.bands.show){this.renderer.initBands.call(this,this.renderer.options,an)}if(this._stack){this.renderer.smooth=false}var am={lineJoin:this.lineJoin,lineCap:this.lineCap,fill:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.fillColor,lineWidth:this.lineWidth,linePattern:this.linePattern,closePath:this.fill};this.renderer.shapeRenderer.init(am);var aj=ai.shadowOffset;if(aj==null){if(this.lineWidth>2.5){aj=1.25*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{aj=1.25*Math.atan((this.lineWidth/2.5))/0.785398163}}var ah={lineJoin:this.lineJoin,lineCap:this.lineCap,fill:this.fill,isarc:false,angle:this.shadowAngle,offset:aj,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.lineWidth,linePattern:this.linePattern,closePath:this.fill};this.renderer.shadowRenderer.init(ah);this._areaPoints=[];this._boundingBox=[[],[]];if(!this.isTrendline&&this.fill||this.renderer.bands.show){this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColor=null;if(al.highlightMouseDown&&al.highlightMouseOver==null){al.highlightMouseOver=false}L.extend(true,this,{highlightMouseOver:al.highlightMouseOver,highlightMouseDown:al.highlightMouseDown,highlightColor:al.highlightColor});if(!this.highlightColor){var ak=(this.renderer.bands.show)?this.renderer.bands.fillColor:this.fillColor;this.highlightColor=L.jqplot.computeHighlightColors(ak)}if(this.highlighter){this.highlighter.show=false}}if(!this.isTrendline&&an){an.plugins.lineRenderer={};an.postInitHooks.addOnce(z);an.postDrawHooks.addOnce(af);an.eventListenerHooks.addOnce("jqplotMouseMove",h);an.eventListenerHooks.addOnce("jqplotMouseDown",e);an.eventListenerHooks.addOnce("jqplotMouseUp",ad);an.eventListenerHooks.addOnce("jqplotClick",g);an.eventListenerHooks.addOnce("jqplotRightClick",s)}};L.jqplot.LineRenderer.prototype.initBands=function(ak,av){var al=ak.bandData||[];var an=this.renderer.bands;an.hiData=[];an.lowData=[];var aB=this.data;an._max=null;an._min=null;if(al.length==2){if(L.isArray(al[0][0])){var ao;var ah=0,ar=0;for(var aw=0,at=al[0].length;awan._max)||an._max==null){an._max=ao[1]}if((ao[1]!=null&&ao[1]an._max)||an._max==null){an._max=ao[1];ar=1}if((ao[1]!=null&&ao[1]al[1][0])?0:1;var aC=(aj)?0:1;for(var aw=0,at=aB.length;aw2&&!L.isArray(al[0][0])){var aj=(al[0][0]>al[0][1])?0:1;var aC=(aj)?0:1;for(var aw=0,at=al.length;awan._max)||an._max==null){an._max=am[aw][1]}}for(var aw=0,at=ap.length;aw0){aR=Math.abs((ap[aQ][1]-ap[aQ-1][1])/(ap[aQ][0]-ap[aQ-1][0]))}am=aR/aG+aE;aM=aF*A(am)-aF*A(aE)+aS;aT=(aO+aM)/2}else{aT=aU}for(aK=0;aK2){var ao;if(this.renderer.constrainSmoothing){ao=J.call(this,this.gridData);this.renderer._smoothedData=ao[0];this.renderer._smoothedPlotData=ao[1];if(ak.show){ao=J.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ao[0];ao=J.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ao[0]}ao=null}else{ao=F.call(this,this.gridData);this.renderer._smoothedData=ao[0];this.renderer._smoothedPlotData=ao[1];if(ak.show){ao=F.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ao[0];ao=F.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ao[0]}ao=null}}};L.jqplot.LineRenderer.prototype.makeGridData=function(ao,aq){var am=this._xaxis.series_u2p;var ah=this._yaxis.series_u2p;var ar=[];var aj=[];this.renderer._smoothedData=[];this.renderer._smoothedPlotData=[];this.renderer._hiBandGridData=[];this.renderer._lowBandGridData=[];this.renderer._hiBandSmoothedData=[];this.renderer._lowBandSmoothedData=[];var al=this.renderer.bands;var ai=false;for(var an=0;an2){var ap;if(this.renderer.constrainSmoothing){ap=J.call(this,ar);this.renderer._smoothedData=ap[0];this.renderer._smoothedPlotData=ap[1];if(al.show){ap=J.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ap[0];ap=J.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ap[0]}ap=null}else{ap=F.call(this,ar);this.renderer._smoothedData=ap[0];this.renderer._smoothedPlotData=ap[1];if(al.show){ap=F.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ap[0];ap=F.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ap[0]}ap=null}}return ar};L.jqplot.LineRenderer.prototype.draw=function(ax,aI,ai,aB){var aC;var aq=L.extend(true,{},ai);var ak=(aq.shadow!=u)?aq.shadow:this.shadow;var aJ=(aq.showLine!=u)?aq.showLine:this.showLine;var aA=(aq.fill!=u)?aq.fill:this.fill;var ah=(aq.fillAndStroke!=u)?aq.fillAndStroke:this.fillAndStroke;var ar,ay,av,aE;ax.save();if(aI.length){if(aJ){if(aA){if(this.fillToZero){var aF=this.negativeColor;if(!this.useNegativeColors){aF=aq.fillStyle}var ao=false;var ap=aq.fillStyle;if(ah){var aH=aI.slice(0)}if(this.index==0||!this._stack){var aw=[];var aL=(this.renderer.smooth)?this.renderer._smoothedPlotData:this._plotData;this._areaPoints=[];var aG=this._yaxis.series_u2p(this.fillToValue);var aj=this._xaxis.series_u2p(this.fillToValue);aq.closePath=true;if(this.fillAxis=="y"){aw.push([aI[0][0],aG]);this._areaPoints.push([aI[0][0],aG]);for(var aC=0;aC0;aC--){aI.push(au[aC-1])}if(ak){this.renderer.shadowRenderer.draw(ax,aI,aq)}this._areaPoints=aI;this.renderer.shapeRenderer.draw(ax,aI,aq)}}else{if(ah){var aH=aI.slice(0)}if(this.index==0||!this._stack){var al=ax.canvas.height;aI.unshift([aI[0][0],al]);var aD=aI.length;aI.push([aI[aD-1][0],al])}else{var au=this._prevGridData;for(var aC=au.length;aC>0;aC--){aI.push(au[aC-1])}}this._areaPoints=aI;if(ak){this.renderer.shadowRenderer.draw(ax,aI,aq)}this.renderer.shapeRenderer.draw(ax,aI,aq)}if(ah){var az=L.extend(true,{},aq,{fill:false,closePath:false});this.renderer.shapeRenderer.draw(ax,aH,az);if(this.markerRenderer.show){if(this.renderer.smooth){aH=this.gridData}for(aC=0;aCat[0]||ar==null){ar=at[0]}if(aEat[1]||ay==null){ay=at[1]}}if(this.type==="line"&&this.renderer.bands.show){aE=this._yaxis.series_u2p(this.renderer.bands._min);ay=this._yaxis.series_u2p(this.renderer.bands._max)}this._boundingBox=[[ar,aE],[av,ay]];if(this.markerRenderer.show&&!aA){if(this.renderer.smooth){aI=this.gridData}for(aC=0;aCao){ao=aj}}}al=null;am=null;if(ah){ai=this._label._elem.outerWidth(true);an=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){ao=ao+an;this._elem.css({height:ao+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){ao=ao+an;this._elem.css({height:ao+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){ao=ao+ai;this._elem.css({width:ao+"px",left:"0px",top:"0px"});if(ah&&this._label.constructor==L.jqplot.AxisLabelRenderer){this._label._elem.css("width",ai+"px")}}else{ao=ao+ai;this._elem.css({width:ao+"px",right:"0px",top:"0px"});if(ah&&this._label.constructor==L.jqplot.AxisLabelRenderer){this._label._elem.css("width",ai+"px")}}}}}};L.jqplot.LinearAxisRenderer.prototype.createTicks=function(aj){var aT=this._ticks;var aK=this.ticks;var az=this.name;var aB=this._dataBounds;var ah=(this.name.charAt(0)==="x")?this._plotDimensions.width:this._plotDimensions.height;var an;var a6,aI;var ap,ao;var a4,a0;var aH=this.min;var a5=this.max;var aW=this.numberTicks;var ba=this.tickInterval;var am=30;this._scalefact=(Math.max(ah,am+1)-am)/300;if(aK.length){for(a0=0;a0this.breakPoints[0]&&aO[0]<=this.breakPoints[1]){aU.show=false;aU.showGridline=false;aU.label=aO[1]}else{aU.label=aO[1]}}}else{aU.label=aO[1]}aU.setTick(aO[0],this.name);this._ticks.push(aU)}else{if(L.isPlainObject(aO)){L.extend(true,aU,aO);aU.axis=this.name;this._ticks.push(aU)}else{aU.value=aO;if(this.breakPoints){if(aO==this.breakPoints[0]){aU.label=this.breakTickLabel;aU._breakTick=true;aU.showGridline=false;aU.showMark=false}else{if(aO>this.breakPoints[0]&&aO<=this.breakPoints[1]){aU.show=false;aU.showGridline=false}}}aU.setTick(aO,this.name);this._ticks.push(aU)}}}this.numberTicks=aK.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1)}else{if(az=="xaxis"||az=="x2axis"){ah=this._plotDimensions.width}else{ah=this._plotDimensions.height}var ax=this.numberTicks;if(this.alignTicks){if(this.name==="x2axis"&&aj.axes.xaxis.show){ax=aj.axes.xaxis.numberTicks}else{if(this.name.charAt(0)==="y"&&this.name!=="yaxis"&&this.name!=="yMidAxis"&&aj.axes.yaxis.show){ax=aj.axes.yaxis.numberTicks}}}a6=((this.min!=null)?this.min:aB.min);aI=((this.max!=null)?this.max:aB.max);var av=aI-a6;var aS,ay;var at;if(this.tickOptions==null||!this.tickOptions.formatString){this._overrideFormatString=true}if(this.min==null||this.max==null&&this.tickInterval==null&&!this.autoscale){if(this.forceTickAt0){if(a6>0){a6=0}if(aI<0){aI=0}}if(this.forceTickAt100){if(a6>100){a6=100}if(aI<100){aI=100}}var aE=false,a1=false;if(this.min!=null){aE=true}else{if(this.max!=null){a1=true}}var aP=L.jqplot.LinearTickGenerator(a6,aI,this._scalefact,ax,aE,a1);var aw=(this.min!=null)?a6:a6+av*(this.padMin-1);var aQ=(this.max!=null)?aI:aI-av*(this.padMax-1);if(a6aQ){aw=(this.min!=null)?a6:a6-av*(this.padMin-1);aQ=(this.max!=null)?aI:aI+av*(this.padMax-1);aP=L.jqplot.LinearTickGenerator(aw,aQ,this._scalefact,ax,aE,a1)}this.min=aP[0];this.max=aP[1];this.numberTicks=aP[2];this._autoFormatString=aP[3];this.tickInterval=aP[4]}else{if(a6==aI){var ai=0.05;if(a6>0){ai=Math.max(Math.log(a6)/Math.LN10,0.05)}a6-=ai;aI+=ai}if(this.autoscale&&this.min==null&&this.max==null){var ak,al,ar;var aC=false;var aN=false;var aA={min:null,max:null,average:null,stddev:null};for(var a0=0;a0a2){a2=aR[aZ]}}}var au=(a2-aG)/a2;if(aV.renderer.constructor==L.jqplot.BarRenderer){if(aG>=0&&(aV.fillToZero||au>0.1)){aC=true}else{aC=false;if(aV.fill&&aV.fillToZero&&aG<0&&a2>0){aN=true}else{aN=false}}}else{if(aV.fill){if(aG>=0&&(aV.fillToZero||au>0.1)){aC=true}else{if(aG<0&&a2>0&&aV.fillToZero){aC=false;aN=true}else{aC=false;aN=false}}}else{if(aG<0){aC=false}}}}}if(aC){this.numberTicks=2+Math.ceil((ah-(this.tickSpacing-1))/this.tickSpacing);this.min=0;aH=0;al=aI/(this.numberTicks-1);at=Math.pow(10,Math.abs(Math.floor(Math.log(al)/Math.LN10)));if(al/at==parseInt(al/at,10)){al+=at}this.tickInterval=Math.ceil(al/at)*at;this.max=this.tickInterval*(this.numberTicks-1)}else{if(aN){this.numberTicks=2+Math.ceil((ah-(this.tickSpacing-1))/this.tickSpacing);var aJ=Math.ceil(Math.abs(a6)/av*(this.numberTicks-1));var a9=this.numberTicks-1-aJ;al=Math.max(Math.abs(a6/aJ),Math.abs(aI/a9));at=Math.pow(10,Math.abs(Math.floor(Math.log(al)/Math.LN10)));this.tickInterval=Math.ceil(al/at)*at;this.max=this.tickInterval*a9;this.min=-this.tickInterval*aJ}else{if(this.numberTicks==null){if(this.tickInterval){this.numberTicks=3+Math.ceil(av/this.tickInterval)}else{this.numberTicks=2+Math.ceil((ah-(this.tickSpacing-1))/this.tickSpacing)}}if(this.tickInterval==null){al=av/(this.numberTicks-1);if(al<1){at=Math.pow(10,Math.abs(Math.floor(Math.log(al)/Math.LN10)))}else{at=1}this.tickInterval=Math.ceil(al*at*this.pad)/at}else{at=1/this.tickInterval}ak=this.tickInterval*(this.numberTicks-1);ar=(ak-av)/2;if(this.min==null){this.min=Math.floor(at*(a6-ar))/at}if(this.max==null){this.max=this.min+ak}}}var aF=L.jqplot.getSignificantFigures(this.tickInterval);var aM;if(aF.digitsLeft>=aF.significantDigits){aM="%d"}else{var at=Math.max(0,5-aF.digitsLeft);at=Math.min(at,aF.digitsRight);aM="%."+at+"f"}this._autoFormatString=aM}else{aS=(this.min!=null)?this.min:a6-av*(this.padMin-1);ay=(this.max!=null)?this.max:aI+av*(this.padMax-1);av=ay-aS;if(this.numberTicks==null){if(this.tickInterval!=null){this.numberTicks=Math.ceil((ay-aS)/this.tickInterval)+1}else{if(ah>100){this.numberTicks=parseInt(3+(ah-100)/75,10)}else{this.numberTicks=2}}}if(this.tickInterval==null){this.tickInterval=av/(this.numberTicks-1)}if(this.max==null){ay=aS+this.tickInterval*(this.numberTicks-1)}if(this.min==null){aS=ay-this.tickInterval*(this.numberTicks-1)}var aF=L.jqplot.getSignificantFigures(this.tickInterval);var aM;if(aF.digitsLeft>=aF.significantDigits){aM="%d"}else{var at=Math.max(0,5-aF.digitsLeft);at=Math.min(at,aF.digitsRight);aM="%."+at+"f"}this._autoFormatString=aM;this.min=aS;this.max=ay}if(this.renderer.constructor==L.jqplot.LinearAxisRenderer&&this._autoFormatString==""){av=this.max-this.min;var a7=new this.tickRenderer(this.tickOptions);var aL=a7.formatString||L.jqplot.config.defaultTickFormatString;var aL=aL.match(L.jqplot.sprintf.regex)[0];var a3=0;if(aL){if(aL.search(/[fFeEgGpP]/)>-1){var aY=aL.match(/\%\.(\d{0,})?[eEfFgGpP]/);if(aY){a3=parseInt(aY[1],10)}else{a3=6}}else{if(aL.search(/[di]/)>-1){a3=0}}var aq=Math.pow(10,-a3);if(this.tickIntervalthis.breakPoints[0]&&aAthis.breakPoints[0]&&aAthis.breakPoints[0]&&aA=this.breakPoints[1]){return(aA-au)*ak/al}else{return(aA+this.breakPoints[1]-this.breakPoints[0]-au)*ak/al}};this.series_p2u=function(aA){return aA*al/ak+au}}}else{this.p2u=function(aA){return(aA-am)*al/ak+at};this.u2p=function(aA){return(aA-at)*ak/al+am};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(aA){return(aA-at)*ak/al};this.series_p2u=function(aA){return aA*al/ak+at}}else{this.series_u2p=function(aA){return(aA-au)*ak/al};this.series_p2u=function(aA){return aA*al/ak+au}}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(var av=0;av0){ah=-ap._textRenderer.height*Math.cos(-ap._textRenderer.angle)/2}else{ah=-ap.getHeight()+ap._textRenderer.height*Math.cos(ap._textRenderer.angle)/2}break;case"middle":ah=-ap.getHeight()/2;break;default:ah=-ap.getHeight()/2;break}}else{ah=-ap.getHeight()/2}var az=this.u2p(ap.value)+ah+"px";ap._elem.css("top",az);ap.pack()}}if(aq){var aw=this._label._elem.outerHeight(true);this._label._elem.css("top",ao-ak/2-aw/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}ay=null};function i(ai){var ah;ai=Math.abs(ai);if(ai>=10){ah="%d"}else{if(ai>1){if(ai===parseInt(ai,10)){ah="%d"}else{ah="%.1f"}}else{var aj=-Math.floor(Math.log(ai)/Math.LN10);ah="%."+aj+"f"}}return ah}var b=[0.1,0.2,0.3,0.4,0.5,0.8,1,2,3,4,5];var c=function(ai){var ah=b.indexOf(ai);if(ah>0){return b[ah-1]}else{return b[b.length-1]/100}};var k=function(ai){var ah=b.indexOf(ai);if(ah5){ah=10*aj}else{if(am>2){ah=5*aj}else{if(am>1){ah=2*aj}else{ah=aj}}}}else{if(am>5){ah=10*aj}else{if(am>4){ah=5*aj}else{if(am>3){ah=4*aj}else{if(am>2){ah=3*aj}else{if(am>1){ah=2*aj}else{ah=aj}}}}}}return ah}function Q(ai,ah){ah=ah||1;var ak=Math.floor(Math.log(ai)/Math.LN10);var am=Math.pow(10,ak);var al=ai/am;var aj;al=al/ah;if(al<=0.38){aj=0.1}else{if(al<=1.6){aj=0.2}else{if(al<=4){aj=0.5}else{if(al<=8){aj=1}else{if(al<=16){aj=2}else{aj=5}}}}}return aj*am}function x(aj,ai){var al=Math.floor(Math.log(aj)/Math.LN10);var an=Math.pow(10,al);var am=aj/an;var ah;var ak;am=am/ai;if(am<=0.38){ak=0.1}else{if(am<=1.6){ak=0.2}else{if(am<=4){ak=0.5}else{if(am<=8){ak=1}else{if(am<=16){ak=2}else{ak=5}}}}}ah=ak*an;return[ah,ak,an]}L.jqplot.LinearTickGenerator=function(an,aq,aj,ak,ao,ar){ao=(ao===null)?false:ao;ar=(ar===null||ao)?false:ar;if(an===aq){aq=(aq)?0:1}aj=aj||1;if(aqat){at=aB}if(ai>aA){aA=ai}})}an.width=at+Number(av);an.height=aA+Number(ax);var ak=an.getContext("2d");ak.save();ak.fillStyle=al;ak.fillRect(0,0,an.width,an.height);ak.restore();ak.translate(au,ar);ak.textAlign="left";ak.textBaseline="top";function aC(aE){var aF=parseInt(L(aE).css("line-height"),10);if(isNaN(aF)){aF=parseInt(L(aE).css("font-size"),10)*1.2}return aF}function aD(aF,aE,aS,aG,aO,aH){var aQ=aC(aF);var aK=L(aF).innerWidth();var aL=L(aF).innerHeight();var aN=aS.split(/\s+/);var aR=aN.length;var aP="";var aM=[];var aU=aO;var aT=aG;for(var aJ=0;aJaK){aM.push(aJ);aP="";aJ--}}if(aM.length===0){if(L(aF).css("textAlign")==="center"){aT=aG+(aH-aE.measureText(aP).width)/2-au}aE.fillText(aS,aT,aO)}else{aP=aN.slice(0,aM[0]).join(" ");if(L(aF).css("textAlign")==="center"){aT=aG+(aH-aE.measureText(aP).width)/2-au}aE.fillText(aP,aT,aU);aU+=aQ;for(var aJ=1,aI=aM.length;aJ0){ak.strokeRect(aI,aL,L(aG).innerWidth(),L(aG).innerHeight())}L(aG).find("div.jqplot-table-legend-swatch-outline").each(function(){var aU=L(this);ak.strokeStyle=aU.css("border-top-color");var aQ=aI+aU.position().left;var aR=aL+aU.position().top;ak.strokeRect(aQ,aR,aU.innerWidth(),aU.innerHeight());aQ+=parseInt(aU.css("padding-left"),10);aR+=parseInt(aU.css("padding-top"),10);var aT=aU.innerHeight()-2*parseInt(aU.css("padding-top"),10);var aP=aU.innerWidth()-2*parseInt(aU.css("padding-left"),10);var aS=aU.children("div.jqplot-table-legend-swatch");ak.fillStyle=aS.css("background-color");ak.fillRect(aQ,aR,aP,aT)});L(aG).find("td.jqplot-table-legend-label").each(function(){var aR=L(this);var aP=aI+aR.position().left;var aQ=aL+aR.position().top+parseInt(aR.css("padding-top"),10);ak.font=aR.jqplotGetComputedFontStyle();ak.fillStyle=aR.css("color");aD(aR,ak,aR.text(),aP,aQ,aM)});var aH=null}else{if(aN=="canvas"){ak.drawImage(aG,aI,aL)}}}}L(this).children().each(function(){aw(this,av,ax)});return an};L.fn.jqplotToImageStr=function(ai){var ah=L(this).jqplotToImageCanvas(ai);if(ah){return ah.toDataURL("image/png")}else{return null}};L.fn.jqplotToImageElem=function(ah){var ai=document.createElement("img");var aj=L(this).jqplotToImageStr(ah);ai.src=aj;return ai};L.fn.jqplotToImageElemStr=function(ah){var ai="";return ai};L.fn.jqplotSaveImage=function(){var ah=L(this).jqplotToImageStr({});if(ah){window.location.href=ah.replace("image/png","image/octet-stream")}};L.fn.jqplotViewImage=function(){var ai=L(this).jqplotToImageElemStr({});var aj=L(this).jqplotToImageStr({});if(ai){var ah=window.open("");ah.document.open("image/png");ah.document.write(ai);ah.document.close();ah=null}};var ag=function(){this.syntax=ag.config.syntax;this._type="jsDate";this.proxy=new Date();this.options={};this.locale=ag.regional.getLocale();this.formatString="";this.defaultCentury=ag.config.defaultCentury;switch(arguments.length){case 0:break;case 1:if(l(arguments[0])=="[object Object]"&&arguments[0]._type!="jsDate"){var aj=this.options=arguments[0];this.syntax=aj.syntax||this.syntax;this.defaultCentury=aj.defaultCentury||this.defaultCentury;this.proxy=ag.createDate(aj.date)}else{this.proxy=ag.createDate(arguments[0])}break;default:var ah=[];for(var ai=0;ai0?"floor":"ceil"](ak))};ag.prototype.getAbbrDayName=function(){return ag.regional[this.locale]["dayNamesShort"][this.proxy.getDay()]};ag.prototype.getAbbrMonthName=function(){return ag.regional[this.locale]["monthNamesShort"][this.proxy.getMonth()]};ag.prototype.getAMPM=function(){return this.proxy.getHours()>=12?"PM":"AM"};ag.prototype.getAmPm=function(){return this.proxy.getHours()>=12?"pm":"am"};ag.prototype.getCentury=function(){return parseInt(this.proxy.getFullYear()/100,10)};ag.prototype.getDate=function(){return this.proxy.getDate()};ag.prototype.getDay=function(){return this.proxy.getDay()};ag.prototype.getDayOfWeek=function(){var ah=this.proxy.getDay();return ah===0?7:ah};ag.prototype.getDayOfYear=function(){var ai=this.proxy;var ah=ai-new Date(""+ai.getFullYear()+"/1/1 GMT");ah+=ai.getTimezoneOffset()*60000;ai=null;return parseInt(ah/60000/60/24,10)+1};ag.prototype.getDayName=function(){return ag.regional[this.locale]["dayNames"][this.proxy.getDay()]};ag.prototype.getFullWeekOfYear=function(){var ak=this.proxy;var ah=this.getDayOfYear();var aj=6-ak.getDay();var ai=parseInt((ah+aj)/7,10);return ai};ag.prototype.getFullYear=function(){return this.proxy.getFullYear()};ag.prototype.getGmtOffset=function(){var ah=this.proxy.getTimezoneOffset()/60;var ai=ah<0?"+":"-";ah=Math.abs(ah);return ai+N(Math.floor(ah),2)+":"+N((ah%1)*60,2)};ag.prototype.getHours=function(){return this.proxy.getHours()};ag.prototype.getHours12=function(){var ah=this.proxy.getHours();return ah>12?ah-12:(ah==0?12:ah)};ag.prototype.getIsoWeek=function(){var ak=this.proxy;var aj=this.getWeekOfYear();var ah=(new Date(""+ak.getFullYear()+"/1/1")).getDay();var ai=aj+(ah>4||ah<=1?0:1);if(ai==53&&(new Date(""+ak.getFullYear()+"/12/31")).getDay()<4){ai=1}else{if(ai===0){ak=new ag(new Date(""+(ak.getFullYear()-1)+"/12/31"));ai=ak.getIsoWeek()}}ak=null;return ai};ag.prototype.getMilliseconds=function(){return this.proxy.getMilliseconds()};ag.prototype.getMinutes=function(){return this.proxy.getMinutes()};ag.prototype.getMonth=function(){return this.proxy.getMonth()};ag.prototype.getMonthName=function(){return ag.regional[this.locale]["monthNames"][this.proxy.getMonth()]};ag.prototype.getMonthNumber=function(){return this.proxy.getMonth()+1};ag.prototype.getSeconds=function(){return this.proxy.getSeconds()};ag.prototype.getShortYear=function(){return this.proxy.getYear()%100};ag.prototype.getTime=function(){return this.proxy.getTime()};ag.prototype.getTimezoneAbbr=function(){return this.proxy.toString().replace(/^.*\(([^)]+)\)$/,"$1")};ag.prototype.getTimezoneName=function(){var ah=/(?:\((.+)\)$| ([A-Z]{3}) )/.exec(this.toString());return ah[1]||ah[2]||"GMT"+this.getGmtOffset()};ag.prototype.getTimezoneOffset=function(){return this.proxy.getTimezoneOffset()};ag.prototype.getWeekOfYear=function(){var ah=this.getDayOfYear();var aj=7-this.getDayOfWeek();var ai=parseInt((ah+aj)/7,10);return ai};ag.prototype.getUnix=function(){return Math.round(this.proxy.getTime()/1000,0)};ag.prototype.getYear=function(){return this.proxy.getYear()};ag.prototype.next=function(ah){ah=ah||"day";return this.clone().add(1,ah)};ag.prototype.set=function(){switch(arguments.length){case 0:this.proxy=new Date();break;case 1:if(l(arguments[0])=="[object Object]"&&arguments[0]._type!="jsDate"){var aj=this.options=arguments[0];this.syntax=aj.syntax||this.syntax;this.defaultCentury=aj.defaultCentury||this.defaultCentury;this.proxy=ag.createDate(aj.date)}else{this.proxy=ag.createDate(arguments[0])}break;default:var ah=[];for(var ai=0;ai0?"floor":"ceil"](ah/12));var ai=aj.getMonth()+(ah%12);if(ai==12){ai=0;aj.setYear(aj.getFullYear()+1)}else{if(ai==-1){ai=11;aj.setYear(aj.getFullYear()-1)}}aj.setMonth(ai)},diff:function(al,aj){var ah=al.getFullYear()-aj.getFullYear();var ai=al.getMonth()-aj.getMonth()+(ah*12);var ak=al.getDate()-aj.getDate();return ai+(ak/30)}},year:{add:function(ai,ah){ai.setYear(ai.getFullYear()+Math[ah>0?"floor":"ceil"](ah))},diff:function(ai,ah){return E.month.diff(ai,ah)/12}}};for(var Y in E){if(Y.substring(Y.length-1)!="s"){E[Y+"s"]=E[Y]}}var H=function(al,ak,ai){if(ag.formats[ai]["shortcuts"][ak]){return ag.strftime(al,ag.formats[ai]["shortcuts"][ak],ai)}else{var ah=(ag.formats[ai]["codes"][ak]||"").split(".");var aj=al["get"+ah[0]]?al["get"+ah[0]]():"";if(ah[1]){aj=N(aj,ah[1])}return aj}};ag.strftime=function(an,ak,aj,ao){var ai="perl";var am=ag.regional.getLocale();if(aj&&ag.formats.hasOwnProperty(aj)){ai=aj}else{if(aj&&ag.regional.hasOwnProperty(aj)){am=aj}}if(ao&&ag.formats.hasOwnProperty(ao)){ai=ao}else{if(ao&&ag.regional.hasOwnProperty(ao)){am=ao}}if(l(an)!="[object Object]"||an._type!="jsDate"){an=new ag(an);an.locale=am}if(!ak){ak=an.formatString||ag.regional[am]["formatString"]}var ah=ak||"%Y-%m-%d",ap="",al;while(ah.length>0){if(al=ah.match(ag.formats[ai].codes.matcher)){ap+=ah.slice(0,al.index);ap+=(al[1]||"")+H(an,al[2],ai);ah=ah.slice(al.index+al[0].length)}else{ap+=ah;ah=""}}return ap};ag.formats={ISO:"%Y-%m-%dT%H:%M:%S.%N%G",SQL:"%Y-%m-%d %H:%M:%S"};ag.formats.perl={codes:{matcher:/()%(#?(%|[a-z]))/i,Y:"FullYear",y:"ShortYear.2",m:"MonthNumber.2","#m":"MonthNumber",B:"MonthName",b:"AbbrMonthName",d:"Date.2","#d":"Date",e:"Date",A:"DayName",a:"AbbrDayName",w:"Day",H:"Hours.2","#H":"Hours",I:"Hours12.2","#I":"Hours12",p:"AMPM",M:"Minutes.2","#M":"Minutes",S:"Seconds.2","#S":"Seconds",s:"Unix",N:"Milliseconds.3","#N":"Milliseconds",O:"TimezoneOffset",Z:"TimezoneName",G:"GmtOffset"},shortcuts:{F:"%Y-%m-%d",T:"%H:%M:%S",X:"%H:%M:%S",x:"%m/%d/%y",D:"%m/%d/%y","#c":"%a %b %e %H:%M:%S %Y",v:"%e-%b-%Y",R:"%H:%M",r:"%I:%M:%S %p",t:"\t",n:"\n","%":"%"}};ag.formats.php={codes:{matcher:/()%((%|[a-z]))/i,a:"AbbrDayName",A:"DayName",d:"Date.2",e:"Date",j:"DayOfYear.3",u:"DayOfWeek",w:"Day",U:"FullWeekOfYear.2",V:"IsoWeek.2",W:"WeekOfYear.2",b:"AbbrMonthName",B:"MonthName",m:"MonthNumber.2",h:"AbbrMonthName",C:"Century.2",y:"ShortYear.2",Y:"FullYear",H:"Hours.2",I:"Hours12.2",l:"Hours12",p:"AMPM",P:"AmPm",M:"Minutes.2",S:"Seconds.2",s:"Unix",O:"TimezoneOffset",z:"GmtOffset",Z:"TimezoneAbbr"},shortcuts:{D:"%m/%d/%y",F:"%Y-%m-%d",T:"%H:%M:%S",X:"%H:%M:%S",x:"%m/%d/%y",R:"%H:%M",r:"%I:%M:%S %p",t:"\t",n:"\n","%":"%"}};ag.createDate=function(aj){if(aj==null){return new Date()}if(aj instanceof Date){return aj}if(typeof aj=="number"){return new Date(aj)}var ao=String(aj).replace(/^\s*(.+)\s*$/g,"$1");ao=ao.replace(/^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,4})/,"$1/$2/$3");ao=ao.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{4})/i,"$1 $2 $3");var an=ao.match(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i);if(an&&an.length>3){var at=parseFloat(an[3]);var am=ag.config.defaultCentury+at;am=String(am);ao=ao.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i,an[1]+" "+an[2]+" "+am)}an=ao.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})[^0-9]/);function ar(ax,aw){var aC=parseFloat(aw[1]);var aB=parseFloat(aw[2]);var aA=parseFloat(aw[3]);var az=ag.config.defaultCentury;var av,au,aD,ay;if(aC>31){au=aA;aD=aB;av=az+aC}else{au=aB;aD=aC;av=az+aA}ay=aD+"/"+au+"/"+av;return ax.replace(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})/,ay)}if(an&&an.length>3){ao=ar(ao,an)}var an=ao.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})$/);if(an&&an.length>3){ao=ar(ao,an)}var al=0;var ai=ag.matchers.length;var aq,ah,ap=ao,ak;while(al31){ah=an;ai=am+ao}else{ah=ao;ai=am+an}var ap=ab(aj[2],ag.regional[ag.regional.getLocale()]["monthNamesShort"]);if(ap==-1){ap=ab(aj[2],ag.regional[ag.regional.getLocale()]["monthNames"])}ak.setFullYear(ai,ap,ah);ak.setHours(0,0,0,0);return ak}else{return al}}];function ab(aj,ak){if(ak.indexOf){return ak.indexOf(aj)}for(var ah=0,ai=ak.length;ah=ap)?"":Array(1+ap-au.length>>>0).join(aq);return at?au+ar:ar+au}function ak(ar){var aq=new String(ar);for(var ap=10;ap>0;ap--){if(aq==(aq=aq.replace(/^(\d+)(\d{3})/,"$1"+L.jqplot.sprintf.thousandsSeparator+"$2"))){break}}return aq}function aj(av,au,ax,ar,at,aq){var aw=ar-av.length;if(aw>0){var ap=" ";if(aq){ap=" "}if(ax||!at){av=an(av,ar,ap,ax)}else{av=av.slice(0,au.length)+an("",aw,"0",true)+av.slice(au.length)}}return av}function ao(ay,aq,aw,ar,ap,av,ax,au){var at=ay>>>0;aw=aw&&at&&{"2":"0b","8":"0","16":"0x"}[aq]||"";ay=aw+an(at.toString(aq),av||0,"0",false);return aj(ay,aw,ar,ap,ax,au)}function ah(au,av,ar,ap,at,aq){if(ap!=null){au=au.slice(0,ap)}return aj(au,"",av,ar,at,aq)}var ai=arguments,al=0,am=ai[al++];return am.replace(L.jqplot.sprintf.regex,function(aM,ax,ay,aB,aO,aJ,av){if(aM=="%%"){return"%"}var aD=false,az="",aA=false,aL=false,aw=false,au=false;for(var aI=0;ay&&aI-1?6:(av=="d")?0:void (0)}else{if(aJ=="*"){aJ=+ai[al++]}else{if(aJ.charAt(0)=="*"){aJ=+ai[aJ.slice(1,-1)]}else{aJ=+aJ}}}var aF=ax?ai[ax.slice(0,-1)]:ai[al++];switch(av){case"s":if(aF==null){return""}return ah(String(aF),aD,aB,aJ,aA,aw);case"c":return ah(String.fromCharCode(+aF),aD,aB,aJ,aA,aw);case"b":return ao(aF,2,aL,aD,aB,aJ,aA,aw);case"o":return ao(aF,8,aL,aD,aB,aJ,aA,aw);case"x":return ao(aF,16,aL,aD,aB,aJ,aA,aw);case"X":return ao(aF,16,aL,aD,aB,aJ,aA,aw).toUpperCase();case"u":return ao(aF,10,aL,aD,aB,aJ,aA,aw);case"i":var ar=parseInt(+aF,10);if(isNaN(ar)){return""}var aH=ar<0?"-":az;var aK=au?ak(String(Math.abs(ar))):String(Math.abs(ar));aF=aH+an(aK,aJ,"0",false);return aj(aF,aH,aD,aB,aA,aw);case"d":var ar=Math.round(+aF);if(isNaN(ar)){return""}var aH=ar<0?"-":az;var aK=au?ak(String(Math.abs(ar))):String(Math.abs(ar));aF=aH+an(aK,aJ,"0",false);return aj(aF,aH,aD,aB,aA,aw);case"e":case"E":case"f":case"F":case"g":case"G":var ar=+aF;if(isNaN(ar)){return""}var aH=ar<0?"-":az;var at=["toExponential","toFixed","toPrecision"]["efg".indexOf(av.toLowerCase())];var aN=["toString","toUpperCase"]["eEfFgG".indexOf(av)%2];var aK=Math.abs(ar)[at](aJ);var aE=aK.toString().split(".");aE[0]=au?ak(aE[0]):aE[0];aK=aE.join(L.jqplot.sprintf.decimalMark);aF=aH+aK;var aC=aj(aF,aH,aD,aB,aA,aw)[aN]();return aC;case"p":case"P":var ar=+aF;if(isNaN(ar)){return""}var aH=ar<0?"-":az;var aE=String(Number(Math.abs(ar)).toExponential()).split(/e|E/);var aq=(aE[0].indexOf(".")!=-1)?aE[0].length-1:String(ar).length;var aG=(aE[1]<0)?-aE[1]-1:0;if(Math.abs(ar)<1){if(aq+aG<=aJ){aF=aH+Math.abs(ar).toPrecision(aq)}else{if(aq<=aJ-1){aF=aH+Math.abs(ar).toExponential(aq-1)}else{aF=aH+Math.abs(ar).toExponential(aJ-1)}}}else{var ap=(aq<=aJ)?aq:aJ;aF=aH+Math.abs(ar).toPrecision(ap)}var aN=["toString","toUpperCase"]["pP".indexOf(av)%2];return aj(aF,aH,aD,aB,aA,aw)[aN]();case"n":return"";default:return aM}})};L.jqplot.sprintf.thousandsSeparator=",";L.jqplot.sprintf.decimalMark=".";L.jqplot.sprintf.regex=/%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g;L.jqplot.getSignificantFigures=function(al){var an=String(Number(Math.abs(al)).toExponential()).split(/e|E/);var am=(an[0].indexOf(".")!=-1)?an[0].length-1:an[0].length;var ai=(an[1]<0)?-an[1]-1:0;var ah=parseInt(an[1],10);var aj=(ah+1>0)?ah+1:0;var ak=(am<=aj)?0:am-ah-1;return{significantDigits:am,digitsLeft:aj,digitsRight:ak,zeros:ai,exponent:ah}};L.jqplot.getPrecision=function(ah){return L.jqplot.getSignificantFigures(ah).digitsRight};var X=L.uiBackCompat!==false;L.jqplot.effects={effect:{}};var m="jqplot.storage.";L.extend(L.jqplot.effects,{version:"1.9pre",save:function(ai,aj){for(var ah=0;ah").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),ah={width:ai.width(),height:ai.height()},ak=document.activeElement;ai.wrap(al);if(ai[0]===ak||L.contains(ai[0],ak)){L(ak).focus()}al=ai.parent();if(ai.css("position")==="static"){al.css({position:"relative"});ai.css({position:"relative"})}else{L.extend(aj,{position:ai.css("position"),zIndex:ai.css("z-index")});L.each(["top","left","bottom","right"],function(am,an){aj[an]=ai.css(an);if(isNaN(parseInt(aj[an],10))){aj[an]="auto"}});ai.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}ai.css(ah);return al.css(aj).show()},removeWrapper:function(ah){var ai=document.activeElement;if(ah.parent().is(".ui-effects-wrapper")){ah.parent().replaceWith(ah);if(ah[0]===ai||L.contains(ah[0],ai)){L(ai).focus()}}return ah}});function j(ai,ah,aj,ak){if(L.isPlainObject(ai)){return ai}ai={effect:ai};if(ah===u){ah={}}if(L.isFunction(ah)){ak=ah;aj=null;ah={}}if(L.type(ah)==="number"||L.fx.speeds[ah]){ak=aj;aj=ah;ah={}}if(L.isFunction(aj)){ak=aj;aj=null}if(ah){L.extend(ai,ah)}aj=aj||ah.duration;ai.duration=L.fx.off?0:typeof aj==="number"?aj:aj in L.fx.speeds?L.fx.speeds[aj]:L.fx.speeds._default;ai.complete=ak||ah.complete;return ai}function ae(ah){if(!ah||typeof ah==="number"||L.fx.speeds[ah]){return true}if(typeof ah==="string"&&!L.jqplot.effects.effect[ah]){if(X&&L.jqplot.effects[ah]){return false}return true}return false}L.fn.extend({jqplotEffect:function(ap,aq,ai,ao){var an=j.apply(this,arguments),ak=an.mode,al=an.queue,am=L.jqplot.effects.effect[an.effect],ah=!am&&X&&L.jqplot.effects[an.effect];if(L.fx.off||!(am||ah)){if(ak){return this[ak](an.duration,an.complete)}else{return this.each(function(){if(an.complete){an.complete.call(this)}})}}function aj(au){var av=L(this),at=an.complete,aw=an.mode;function ar(){if(L.isFunction(at)){at.call(av[0])}if(L.isFunction(au)){au()}}if(av.is(":hidden")?aw==="hide":aw==="show"){ar()}else{am.call(av[0],an,ar)}}if(am){return al===false?this.each(aj):this.queue(al||"fx",aj)}else{return ah.call(this,{options:an,duration:an.duration,callback:an.complete,mode:an.mode})}}});var a=/up|down|vertical/,v=/up|left|vertical|horizontal/;L.jqplot.effects.effect.blind=function(aj,ao){var ak=L(this),ar=["position","top","bottom","left","right","height","width"],ap=L.jqplot.effects.setMode(ak,aj.mode||"hide"),au=aj.direction||"up",am=a.test(au),al=am?"height":"width",aq=am?"top":"left",aw=v.test(au),an={},av=ap==="show",ai,ah,at;if(ak.parent().is(".ui-effects-wrapper")){L.jqplot.effects.save(ak.parent(),ar)}else{L.jqplot.effects.save(ak,ar)}ak.show();at=parseInt(ak.css("top"),10);ai=L.jqplot.effects.createWrapper(ak).css({overflow:"hidden"});ah=am?ai[al]()+at:ai[al]();an[al]=av?String(ah):"0";if(!aw){ak.css(am?"bottom":"right",0).css(am?"top":"left","").css({position:"absolute"});an[aq]=av?"0":String(ah)}if(av){ai.css(al,0);if(!aw){ai.css(aq,ah)}}ai.animate(an,{duration:aj.duration,easing:aj.easing,queue:false,complete:function(){if(ap==="hide"){ak.hide()}L.jqplot.effects.restore(ak,ar);L.jqplot.effects.removeWrapper(ak);ao()}})}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.BezierCurveRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.BezierCurveRenderer.min.js new file mode 100644 index 000000000..94c6fc5e7 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.BezierCurveRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(b){b.jqplot.BezierCurveRenderer=function(){b.jqplot.LineRenderer.call(this)};b.jqplot.BezierCurveRenderer.prototype=new b.jqplot.LineRenderer();b.jqplot.BezierCurveRenderer.prototype.constructor=b.jqplot.BezierCurveRenderer;b.jqplot.BezierCurveRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var g=this._yaxis.series_u2p;var f=this.data;this.gridData=[];this._prevGridData=[];var d=this.index;if(f.length==2){if(d==0){this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[1][2]),g.call(this._yaxis,f[1][3]),e.call(this._xaxis,f[1][4]),g.call(this._yaxis,f[1][5])],[e.call(this._xaxis,f[1][4]),g.call(this._yaxis,this._yaxis.min)],[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,this._yaxis.min)]]}else{var c=h.series[d-1].data;this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[1][2]),g.call(this._yaxis,f[1][3]),e.call(this._xaxis,f[1][4]),g.call(this._yaxis,f[1][5])],[e.call(this._xaxis,c[1][4]),g.call(this._yaxis,c[1][5])],[e.call(this._xaxis,c[1][2]),g.call(this._yaxis,c[1][3]),e.call(this._xaxis,c[1][0]),g.call(this._yaxis,c[1][1]),e.call(this._xaxis,c[0][0]),g.call(this._yaxis,c[0][1])]]}}else{if(d==0){this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[2][0]),g.call(this._yaxis,f[2][1]),e.call(this._xaxis,f[3][0]),g.call(this._yaxis,f[3][1])],[e.call(this._xaxis,f[3][1]),g.call(this._yaxis,this._yaxis.min)],[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,this._yaxis.min)]]}else{var c=h.series[d-1].data;this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[2][0]),g.call(this._yaxis,f[2][1]),e.call(this._xaxis,f[3][0]),g.call(this._yaxis,f[3][1])],[e.call(this._xaxis,c[3][0]),g.call(this._yaxis,c[3][1])],[e.call(this._xaxis,c[2][0]),g.call(this._yaxis,c[2][1]),e.call(this._xaxis,c[1][0]),g.call(this._yaxis,c[1][1]),e.call(this._xaxis,c[0][0]),g.call(this._yaxis,c[0][1])]]}}};b.jqplot.BezierCurveRenderer.prototype.makeGridData=function(g,i){var f=this._xaxis.series_u2p;var h=this._yaxis.series_u2p;var e=[];var j=[];var d=this.index;if(g.length==2){if(d==0){e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[1][2]),h.call(this._yaxis,g[1][3]),f.call(this._xaxis,g[1][4]),h.call(this._yaxis,g[1][5])],[f.call(this._xaxis,g[1][4]),h.call(this._yaxis,this._yaxis.min)],[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,this._yaxis.min)]]}else{var c=i.series[d-1].data;e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[1][2]),h.call(this._yaxis,g[1][3]),f.call(this._xaxis,g[1][4]),h.call(this._yaxis,g[1][5])],[f.call(this._xaxis,c[1][4]),h.call(this._yaxis,c[1][5])],[f.call(this._xaxis,c[1][2]),h.call(this._yaxis,c[1][3]),f.call(this._xaxis,c[1][0]),h.call(this._yaxis,c[1][1]),f.call(this._xaxis,c[0][0]),h.call(this._yaxis,c[0][1])]]}}else{if(d==0){e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[2][0]),h.call(this._yaxis,g[2][1]),f.call(this._xaxis,g[3][0]),h.call(this._yaxis,g[3][1])],[f.call(this._xaxis,g[3][1]),h.call(this._yaxis,this._yaxis.min)],[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,this._yaxis.min)]]}else{var c=i.series[d-1].data;e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[2][0]),h.call(this._yaxis,g[2][1]),f.call(this._xaxis,g[3][0]),h.call(this._yaxis,g[3][1])],[f.call(this._xaxis,c[3][0]),h.call(this._yaxis,c[3][1])],[f.call(this._xaxis,c[2][0]),h.call(this._yaxis,c[2][1]),f.call(this._xaxis,c[1][0]),h.call(this._yaxis,c[1][1]),f.call(this._xaxis,c[0][0]),h.call(this._yaxis,c[0][1])]]}}return e};b.jqplot.BezierCurveRenderer.prototype.draw=function(c,g,d){var e;c.save();if(g.length){if(this.showLine){c.save();var f=(d!=null)?d:{};c.fillStyle=f.fillStyle||this.color;c.beginPath();c.moveTo(g[0][0],g[0][1]);c.bezierCurveTo(g[1][0],g[1][1],g[1][2],g[1][3],g[1][4],g[1][5]);c.lineTo(g[2][0],g[2][1]);if(g[3].length==2){c.lineTo(g[3][0],g[3][1])}else{c.bezierCurveTo(g[3][0],g[3][1],g[3][2],g[3][3],g[3][4],g[3][5])}c.closePath();c.fill();c.restore()}}c.restore()};b.jqplot.BezierCurveRenderer.prototype.drawShadow=function(c,e,d){};b.jqplot.BezierAxisRenderer=function(){b.jqplot.LinearAxisRenderer.call(this)};b.jqplot.BezierAxisRenderer.prototype=new b.jqplot.LinearAxisRenderer();b.jqplot.BezierAxisRenderer.prototype.constructor=b.jqplot.BezierAxisRenderer;b.jqplot.BezierAxisRenderer.prototype.init=function(f){b.extend(true,this,f);var c=this._dataBounds;for(var g=0;gc.max||c.max==null){c.max=k[e][0]}}else{if(k[e][1]c.max||c.max==null){c.max=k[e][1]}}}}else{if(this.name=="xaxis"||this.name=="x2axis"){if(k[0][0]c.max||c.max==null){c.max=k[0][0]}for(var e=0;e<5;e+=2){if(k[1][e]c.max||c.max==null){c.max=k[1][e]}}}else{if(k[0][1]c.max||c.max==null){c.max=k[0][1]}for(var e=1;e<6;e+=2){if(k[1][e]c.max||c.max==null){c.max=k[1][e]}}}}}};function a(g,f,d){d=d||{};d.axesDefaults=b.extend(true,{pad:0},d.axesDefaults);d.seriesDefaults=d.seriesDefaults||{};d.legend=b.extend(true,{placement:"outside"},d.legend);var c=false;if(d.seriesDefaults.renderer==b.jqplot.BezierCurveRenderer){c=true}else{if(d.series){for(var e=0;e0){this.data[q][u]+=this.data[q-1][u]}}this.data[this.data.length]=(u==1)?[this.data.length+1,s]:[s,this.data.length+1];this._data[this._data.length]=(u==1)?[this._data.length+1,s]:[s,this._data.length+1]}if(this.rendererOptions.groups>1){this.breakOnNull=true;var n=this.data.length;var v=parseInt(n/this.rendererOptions.groups,10);var r=0;for(var q=v;q570)?n[p]*0.8:n[p]+0.3*(255-n[p]);n[p]=parseInt(n[p],10)}q.push("rgb("+n[0]+","+n[1]+","+n[2]+")")}return q}function i(v,u,s,t,o){var q=v,w=v-1,n,p,r=(o==="x")?0:1;if(q>0){p=t.series[w]._plotData[u][r];if((s*p)<0){n=i(w,u,s,t,o)}else{n=t.series[w].gridData[u][r]}}else{n=(r===0)?t.series[q]._xaxis.series_u2p(0):t.series[q]._yaxis.series_u2p(0)}return n}d.jqplot.BarRenderer.prototype.draw=function(E,L,q,G){var I;var A=d.extend({},q);var w=(A.shadow!=undefined)?A.shadow:this.shadow;var O=(A.showLine!=undefined)?A.showLine:this.showLine;var F=(A.fill!=undefined)?A.fill:this.fill;var p=this.xaxis;var J=this.yaxis;var y=this._xaxis.series_u2p;var K=this._yaxis.series_u2p;var D,C;this._dataColors=[];this._barPoints=[];if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var N=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);var x=N[0];var v=N[1];var s=N[2];var H=[];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(v/2-0.5)+s)*(this.barWidth+this.barPadding)}if(O){var u=new d.jqplot.ColorGenerator(this.negativeSeriesColors);var B=new d.jqplot.ColorGenerator(this.seriesColors);var M=u.get(this.index);if(!this.useNegativeColors){M=A.fillStyle}var t=A.fillStyle;var r;var P;var o;if(this.barDirection=="vertical"){for(var I=0;I0&&I=0){o=this._yaxis.series_u2p(0)}else{if(this._yaxis.min>0){o=E.canvas.height}else{o=0}}}else{if(this.waterfall&&I==this.gridData.length-1){if(this._yaxis.min<=0&&this._yaxis.max>=0){o=this._yaxis.series_u2p(0)}else{if(this._yaxis.min>0){o=E.canvas.height}else{o=0}}}else{o=E.canvas.height}}}}}if((this.fillToZero&&this._plotData[I][1]<0)||(this.waterfall&&this._data[I][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){A.fillStyle=u.next()}else{A.fillStyle=B.next()}}else{A.fillStyle=M}}else{if(this.varyBarColor&&!this._stack){A.fillStyle=B.next()}else{A.fillStyle=t}}if(!this.fillToZero||this._plotData[I][1]>=0){H.push([r-this.barWidth/2,o]);H.push([r-this.barWidth/2,L[I][1]]);H.push([r+this.barWidth/2,L[I][1]]);H.push([r+this.barWidth/2,o])}else{H.push([r-this.barWidth/2,L[I][1]]);H.push([r-this.barWidth/2,o]);H.push([r+this.barWidth/2,o]);H.push([r+this.barWidth/2,L[I][1]])}this._barPoints.push(H);if(w&&!this._stack){var z=d.extend(true,{},A);delete z.fillStyle;this.renderer.shadowRenderer.draw(E,H,z)}var n=A.fillStyle||this.color;this._dataColors.push(n);this.renderer.shapeRenderer.draw(E,H,A)}}else{if(this.barDirection=="horizontal"){for(var I=0;I0&&I=0){P=this._xaxis.series_u2p(0)}else{if(this._xaxis.min>0){P=0}else{P=0}}}else{if(this.waterfall&&I==this.gridData.length-1){if(this._xaxis.min<=0&&this._xaxis.max>=0){P=this._xaxis.series_u2p(0)}else{if(this._xaxis.min>0){P=0}else{P=E.canvas.width}}}else{P=0}}}}}if((this.fillToZero&&this._plotData[I][0]<0)||(this.waterfall&&this._data[I][0]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){A.fillStyle=u.next()}else{A.fillStyle=B.next()}}else{A.fillStyle=M}}else{if(this.varyBarColor&&!this._stack){A.fillStyle=B.next()}else{A.fillStyle=t}}if(!this.fillToZero||this._plotData[I][0]>=0){H.push([P,r+this.barWidth/2]);H.push([P,r-this.barWidth/2]);H.push([L[I][0],r-this.barWidth/2]);H.push([L[I][0],r+this.barWidth/2])}else{H.push([L[I][0],r+this.barWidth/2]);H.push([L[I][0],r-this.barWidth/2]);H.push([P,r-this.barWidth/2]);H.push([P,r+this.barWidth/2])}this._barPoints.push(H);if(w&&!this._stack){var z=d.extend(true,{},A);delete z.fillStyle;this.renderer.shadowRenderer.draw(E,H,z)}var n=A.fillStyle||this.color;this._dataColors.push(n);this.renderer.shapeRenderer.draw(E,H,A)}}}}if(this.highlightColors.length==0){this.highlightColors=d.jqplot.computeHighlightColors(this._dataColors)}else{if(typeof(this.highlightColors)=="string"){var N=this.highlightColors;this.highlightColors=[];for(var I=0;I")}k=a.extend(true,{},this.css,k);c=a('
    ');this.canvas._elem.append(c);this.escapeHtml?c.text(p):c.html(p);delete k.position;delete k.marginRight;delete k.marginLeft;if(!k.background&&!k.backgroundColor&&!k.backgroundImage){k.background=j.next()}c.css(k);n=c.outerWidth();g=c.outerHeight();e=o[0]-n/2+"px";m=o[1]-g/2+"px";c.css({left:e,top:m});c=null}};a.jqplot.BlockCanvas=function(){a.jqplot.ElemContainer.call(this);this._ctx};a.jqplot.BlockCanvas.prototype=new a.jqplot.ElemContainer();a.jqplot.BlockCanvas.prototype.constructor=a.jqplot.BlockCanvas;a.jqplot.BlockCanvas.prototype.createElement=function(i,e,c){this._offsets=i;var b="jqplot-blockCanvas";if(e!=undefined){b=e}var g;if(this._elem){g=this._elem.get(0)}else{g=document.createElement("div")}if(c!=undefined){this._plotDimensions=c}var d=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var f=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=a(g);this._elem.css({position:"absolute",width:d,height:f,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(b);return this._elem};a.jqplot.BlockCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.bubbleRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.bubbleRenderer.min.js new file mode 100644 index 000000000..dc0c1ef01 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.bubbleRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(f){var d=function(m){return Math.max.apply(Math,m)};var j=function(m){return Math.min.apply(Math,m)};f.jqplot.BubbleRenderer=function(){f.jqplot.LineRenderer.call(this)};f.jqplot.BubbleRenderer.prototype=new f.jqplot.LineRenderer();f.jqplot.BubbleRenderer.prototype.constructor=f.jqplot.BubbleRenderer;f.jqplot.BubbleRenderer.prototype.init=function(w,t){this.varyBubbleColors=true;this.autoscaleBubbles=true;this.autoscaleMultiplier=1;this.autoscalePointsFactor=-0.07;this.escapeHtml=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.bubbleAlpha=1;this.highlightAlpha=null;this.bubbleGradients=false;this.showLabels=true;this.radii=[];this.maxRadius=0;this._highlightedPoint=null;this.labels=[];this.bubbleCanvases=[];this._type="bubble";if(w.highlightMouseDown&&w.highlightMouseOver==null){w.highlightMouseOver=false}f.extend(true,this,w);if(this.highlightAlpha==null){this.highlightAlpha=this.bubbleAlpha;if(this.bubbleGradients){this.highlightAlpha=0.35}}this.autoscaleMultiplier=this.autoscaleMultiplier*Math.pow(this.data.length,this.autoscalePointsFactor);this._highlightedPoint=null;var n;for(var r=0;r570)?u[q]*0.8:u[q]+0.3*(255-u[q]);u[q]=parseInt(u[q],10)}this.highlightColors.push("rgba("+u[0]+","+u[1]+","+u[2]+", "+this.highlightAlpha+")")}}this.highlightColorGenerator=new f.jqplot.ColorGenerator(this.highlightColors);var m={fill:true,isarc:true,angle:this.shadowAngle,alpha:this.shadowAlpha,closePath:true};this.renderer.shadowRenderer.init(m);this.canvas=new f.jqplot.DivCanvas();this.canvas._plotDimensions=this._plotDimensions;t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",k);t.eventListenerHooks.addOnce("jqplotClick",g);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};f.jqplot.BubbleRenderer.prototype.setGridData=function(w){var q=this._xaxis.series_u2p;var m=this._yaxis.series_u2p;var t=this._plotData;this.gridData=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u');if(this.escapeHtml){p.text(z)}else{p.html(z)}this.canvas._elem.append(p);var H=f(p).outerHeight();var v=f(p).outerWidth();var B=J[1]-0.5*H;var o=J[0]-0.5*v;p.css({top:B,left:o});this.labels[C]=f(p)}}};f.jqplot.DivCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.DivCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.DivCanvas.prototype.constructor=f.jqplot.DivCanvas;f.jqplot.DivCanvas.prototype.createElement=function(s,p,n){this._offsets=s;var m="jqplot-DivCanvas";if(p!=undefined){m=p}var r;if(this._elem){r=this._elem.get(0)}else{r=document.createElement("div")}if(n!=undefined){this._plotDimensions=n}var o=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var q=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=f(r);this._elem.css({position:"absolute",width:o,height:q,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(m);return this._elem};f.jqplot.DivCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx};f.jqplot.BubbleCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.BubbleCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.BubbleCanvas.prototype.constructor=f.jqplot.BubbleCanvas;f.jqplot.BubbleCanvas.prototype.createElement=function(n,u,s){var m="jqplot-bubble-point";var q;if(this._elem){q=this._elem.get(0)}else{q=document.createElement("canvas")}q.width=(s!=null)?2*s:q.width;q.height=(s!=null)?2*s:q.height;this._elem=f(q);var o=(n!=null&&s!=null)?n-s:this._elem.css("left");var p=(u!=null&&s!=null)?u-s:this._elem.css("top");this._elem.css({position:"absolute",left:o,top:p});this._elem.addClass(m);if(f.jqplot.use_excanvas){window.G_vmlCanvasManager.init_(document);q=window.G_vmlCanvasManager.initElement(q)}return this._elem};f.jqplot.BubbleCanvas.prototype.draw=function(m,s,v,p){var D=this._ctx;var B=D.canvas.width/2;var z=D.canvas.height/2;D.save();if(v&&!f.jqplot.use_excanvas){m=m*1.04;var o=f.jqplot.getColorComponents(s);var u="rgba("+Math.round(o[0]+0.8*(255-o[0]))+", "+Math.round(o[1]+0.8*(255-o[1]))+", "+Math.round(o[2]+0.8*(255-o[2]))+", "+o[3]+")";var t="rgba("+o[0]+", "+o[1]+", "+o[2]+", 0)";var C=0.35*m;var A=B-Math.cos(p)*0.33*m;var n=z-Math.sin(p)*0.33*m;var w=D.createRadialGradient(A,n,C,B,z,m);w.addColorStop(0,u);w.addColorStop(0.93,s);w.addColorStop(0.96,t);w.addColorStop(1,t);D.fillStyle=w;D.fillRect(0,0,D.canvas.width,D.canvas.height)}else{D.fillStyle=s;D.strokeStyle=s;D.lineWidth=1;D.beginPath();var q=2*Math.PI;D.arc(B,z,m,0,q,0);D.closePath();D.fill()}D.restore()};f.jqplot.BubbleCanvas.prototype.setContext=function(){this._ctx=this._elem.get(0).getContext("2d");return this._ctx};f.jqplot.BubbleAxisRenderer=function(){f.jqplot.LinearAxisRenderer.call(this)};f.jqplot.BubbleAxisRenderer.prototype=new f.jqplot.LinearAxisRenderer();f.jqplot.BubbleAxisRenderer.prototype.constructor=f.jqplot.BubbleAxisRenderer;f.jqplot.BubbleAxisRenderer.prototype.init=function(n){f.extend(true,this,n);var I=this._dataBounds;var H=0,v=0,m=0,y=0,q=0,r=0,D=0,t=0,F=0,z=0;for(var E=0;EI.max||I.max==null){I.max=G[B][0];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}else{if(G[B][1]I.max||I.max==null){I.max=G[B][1];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}}}var o=r/D;var w=q/t;var C=I.max-I.min;var A=Math.min(this._plotDimensions.width,this._plotDimensions.height);var p=o*z/3*C;var u=w*F/3*C;I.max+=u;I.min-=p};function e(p,v,q){p.plugins.bubbleRenderer.highlightLabelCanvas.empty();var z=p.series[v];var n=p.plugins.bubbleRenderer.highlightCanvas;var w=n._ctx;w.clearRect(0,0,w.canvas.width,w.canvas.height);z._highlightedPoint=q;p.plugins.bubbleRenderer.highlightedSeriesIndex=v;var o=z.highlightColorGenerator.get(q);var u=z.gridData[q][0],t=z.gridData[q][1],m=z.gridData[q][2];w.save();w.fillStyle=o;w.strokeStyle=o;w.lineWidth=1;w.beginPath();w.arc(u,t,m,0,2*Math.PI,0);w.closePath();w.fill();w.restore();if(z.labels[q]){p.plugins.bubbleRenderer.highlightLabel=z.labels[q].clone();p.plugins.bubbleRenderer.highlightLabel.appendTo(p.plugins.bubbleRenderer.highlightLabelCanvas);p.plugins.bubbleRenderer.highlightLabel.addClass("jqplot-bubble-label-highlight")}}function i(p){var m=p.plugins.bubbleRenderer.highlightCanvas;var o=p.plugins.bubbleRenderer.highlightedSeriesIndex;p.plugins.bubbleRenderer.highlightLabelCanvas.empty();m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n');var q=this._gridPadding.top;var p=this._gridPadding.left;var n=this._plotDimensions.width-this._gridPadding.left-this._gridPadding.right;var m=this._plotDimensions.height-this._gridPadding.top-this._gridPadding.bottom;this.plugins.bubbleRenderer.highlightLabelCanvas.css({top:q,left:p,width:n+"px",height:m+"px"});this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-bubbleRenderer-highlight-canvas",this._plotDimensions,this));this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightLabelCanvas);var o=this.plugins.bubbleRenderer.highlightCanvas.setContext()}function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==f.jqplot.BubbleRenderer){m=true}else{if(n.series){for(var o=0;ot){y=w;w=t;t=y}if(v>s){y=v;v=s;s=y}var u=(o>=w&&o<=t&&n>=v&&n<=s);return u}function a(z,w,r,A,x){var y=x.plugins.canvasOverlay;var v=y.objects;var s=v.length;var u,o=false;var q;for(var t=0;t-1){return c/this.pt2px}else{if(b.indexOf("pt")>-1){return c}else{if(b.indexOf("em")>-1){return c*12}else{if(b.indexOf("%")>-1){return c*12/100}else{return c/this.pt2px}}}}};a.jqplot.CanvasTextRenderer.prototype.fontWeight2Float=function(b){if(Number(b)){return b/400}else{switch(b){case"normal":return 1;break;case"bold":return 1.75;break;case"bolder":return 2.25;break;case"lighter":return 0.75;break;default:return 1;break}}};a.jqplot.CanvasTextRenderer.prototype.getText=function(){return this.text};a.jqplot.CanvasTextRenderer.prototype.setText=function(c,b){this.text=c;this.setWidth(b);return this};a.jqplot.CanvasTextRenderer.prototype.getWidth=function(b){return this.width};a.jqplot.CanvasTextRenderer.prototype.setWidth=function(c,b){if(!b){this.width=this.measure(c,this.text)}else{this.width=b}return this};a.jqplot.CanvasTextRenderer.prototype.getHeight=function(b){return this.height};a.jqplot.CanvasTextRenderer.prototype.setHeight=function(b){if(!b){this.height=this.normalizedFontSize*this.pt2px}else{this.height=b}return this};a.jqplot.CanvasTextRenderer.prototype.letter=function(b){return this.letters[b]};a.jqplot.CanvasTextRenderer.prototype.ascent=function(){return this.normalizedFontSize};a.jqplot.CanvasTextRenderer.prototype.descent=function(){return 7*this.normalizedFontSize/25};a.jqplot.CanvasTextRenderer.prototype.measure=function(d,g){var f=0;var b=g.length;for(var e=0;e30)?2:2+(30-this.normalizedFontSize)/20;s.lineWidth=t*k*this.fontWeight2Float(this.fontWeight);for(var g=0;g":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};a.jqplot.CanvasFontRenderer=function(b){b=b||{};if(!b.pt2px){b.pt2px=1.5}a.jqplot.CanvasTextRenderer.call(this,b)};a.jqplot.CanvasFontRenderer.prototype=new a.jqplot.CanvasTextRenderer({});a.jqplot.CanvasFontRenderer.prototype.constructor=a.jqplot.CanvasFontRenderer;a.jqplot.CanvasFontRenderer.prototype.measure=function(c,e){var d=this.fontSize+" "+this.fontFamily;c.save();c.font=d;var b=c.measureText(e).width;c.restore();return b};a.jqplot.CanvasFontRenderer.prototype.draw=function(e,g){var c=0;var h=this.height*0.72;e.save();var d,b;if((-Math.PI/2<=this.angle&&this.angle<=0)||(Math.PI*3/2<=this.angle&&this.angle<=Math.PI*2)){d=0;b=-Math.sin(this.angle)*this.width}else{if((0b.max||b.max==null){b.max=h[c][0]}}else{if(h[c][1]b.max||b.max==null){b.max=h[c][1]}}}}if(this.groupLabels.length){this.groups=this.groupLabels.length}};a.jqplot.CategoryAxisRenderer.prototype.createTicks=function(){var D=this._ticks;var z=this.ticks;var F=this.name;var C=this._dataBounds;var v,A;var q,w;var d,c;var b,x;if(z.length){if(this.groups>1&&!this._grouped){var r=z.length;var p=parseInt(r/this.groups,10);var e=0;for(var x=p;x1&&!this._grouped){var r=y.length;var p=parseInt(r/this.groups,10);var e=0;for(var x=p;x0&&o');if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var g=this._label.draw(b,j);g.appendTo(this._elem)}var f=this._ticks;for(var e=0;e');g.html(this.groupLabels[e]);this._groupLabels.push(g);g.appendTo(this._elem)}}return this._elem};a.jqplot.CategoryAxisRenderer.prototype.set=function(){var e=0;var m;var k=0;var f=0;var d=(this._label==null)?false:this._label.show;if(this.show){var n=this._ticks;for(var c=0;ce){e=m}}}var j=0;for(var c=0;cj){j=m}}if(d){k=this._label._elem.outerWidth(true);f=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){e+=j+f;this._elem.css({height:e+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){e+=j+f;this._elem.css({height:e+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){e+=j+k;this._elem.css({width:e+"px",left:"0px",top:"0px"});if(d&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",k+"px")}}else{e+=j+k;this._elem.css({width:e+"px",right:"0px",top:"0px"});if(d&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",k+"px")}}}}}};a.jqplot.CategoryAxisRenderer.prototype.pack=function(e,c){var C=this._ticks;var v=this.max;var s=this.min;var n=c.max;var l=c.min;var q=(this._label==null)?false:this._label.show;var x;for(var r in e){this._elem.css(r,e[r])}this._offsets=c;var g=n-l;var k=v-s;if(!this.reverse){this.u2p=function(h){return(h-s)*g/k+l};this.p2u=function(h){return(h-l)*k/g+s};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(h){return(h-s)*g/k};this.series_p2u=function(h){return h*k/g+s}}else{this.series_u2p=function(h){return(h-v)*g/k};this.series_p2u=function(h){return h*k/g+v}}}else{this.u2p=function(h){return l+(v-h)*g/k};this.p2u=function(h){return s+(h-l)*k/g};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(h){return(v-h)*g/k};this.series_p2u=function(h){return h*k/g+v}}else{this.series_u2p=function(h){return(s-h)*g/k};this.series_p2u=function(h){return h*k/g+s}}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(x=0;x=this._ticks.length-1){continue}if(this._ticks[u]._elem&&this._ticks[u].label!=" "){var o=this._ticks[u]._elem;var r=o.position();B+=r.left+o.outerWidth(true)/2;f++}}B=B/f;this._groupLabels[x].css({left:(B-this._groupLabels[x].outerWidth(true)/2)});this._groupLabels[x].css(z[0],z[1])}}else{for(x=0;x0){b=-o._textRenderer.height*Math.cos(-o._textRenderer.angle)/2}else{b=-o.getHeight()+o._textRenderer.height*Math.cos(o._textRenderer.angle)/2}break;case"middle":b=-o.getHeight()/2;break;default:b=-o.getHeight()/2;break}}else{b=-o.getHeight()/2}var D=this.u2p(o.value)+b+"px";o._elem.css("top",D);o.pack()}}var z=["left",0];if(q){var y=this._label._elem.outerHeight(true);this._label._elem.css("top",n-g/2-y/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px");z=["left",this._label._elem.outerWidth(true)]}else{this._label._elem.css("right","0px");z=["right",this._label._elem.outerWidth(true)]}this._label.pack()}var d=parseInt(this._ticks.length/this.groups,10)+1;for(x=0;x=this._ticks.length-1){continue}if(this._ticks[u]._elem&&this._ticks[u].label!=" "){var o=this._ticks[u]._elem;var r=o.position();B+=r.top+o.outerHeight()/2;f++}}B=B/f;this._groupLabels[x].css({top:B-this._groupLabels[x].outerHeight()/2});this._groupLabels[x].css(z[0],z[1])}}}}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.ciParser.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.ciParser.min.js new file mode 100644 index 000000000..08f46c851 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.ciParser.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(a){a.jqplot.ciParser=function(g,l){var m=[],o,n,h,f,e,c;if(typeof(g)=="string"){g=a.jqplot.JSON.parse(g,d)}else{if(typeof(g)=="object"){for(e in g){for(h=0;h=0){i=/^\/Date\((-?[0-9]+)\)\/$/.exec(k);if(i){return parseInt(i[1],10)}}return k}}for(var b in g){o=[];n=g[b];switch(b){case"PriceTicks":for(h=0;h6&&Math.abs(G.y-I._zoom.start[1])>6)||(I.constrainZoomTo=="x"&&Math.abs(G.x-I._zoom.start[0])>6)||(I.constrainZoomTo=="y"&&Math.abs(G.y-I._zoom.start[1])>6)){if(!C.plugins.cursor.zoomProxy){for(var y in t){if(I._zoom.axes[y]==undefined){I._zoom.axes[y]={};I._zoom.axes[y].numberTicks=F[y].numberTicks;I._zoom.axes[y].tickInterval=F[y].tickInterval;I._zoom.axes[y].daTickInterval=F[y].daTickInterval;I._zoom.axes[y].min=F[y].min;I._zoom.axes[y].max=F[y].max;I._zoom.axes[y].tickFormatString=(F[y].tickOptions!=null)?F[y].tickOptions.formatString:""}if((I.constrainZoomTo=="none")||(I.constrainZoomTo=="x"&&y.charAt(0)=="x")||(I.constrainZoomTo=="y"&&y.charAt(0)=="y")){z=t[y];if(z!=null){if(z>w[y]){v=w[y];x=z}else{D=w[y]-z;v=z;x=w[y]}q=F[y];H=null;if(q.alignTicks){if(q.name==="x2axis"&&C.axes.xaxis.show){H=C.axes.xaxis.numberTicks}else{if(q.name.charAt(0)==="y"&&q.name!=="yaxis"&&q.name!=="yMidAxis"&&C.axes.yaxis.show){H=C.axes.yaxis.numberTicks}}}if(this.looseZoom&&(F[y].renderer.constructor===j.jqplot.LinearAxisRenderer||F[y].renderer.constructor===j.jqplot.LogAxisRenderer)){J=j.jqplot.LinearTickGenerator(v,x,q._scalefact,H);if(F[y].tickInset&&J[0]F[y].max-F[y].tickInset*F[y].tickInterval){J[1]-=J[4];J[2]-=1}if(F[y].renderer.constructor===j.jqplot.LogAxisRenderer&&J[0]"}if(J.useAxesFormatters){for(var D=0;D"}w+=j.jqplot.sprintf(J.tooltipFormatString,t,z,x);N=true}}}}J._tooltipElem.html(w)}function g(C,A){var E=A.plugins.cursor;var z=E.cursorCanvas._ctx;z.clearRect(0,0,z.canvas.width,z.canvas.height);if(E.showVerticalLine){E.shapeRenderer.draw(z,[[C.x,0],[C.x,z.canvas.height]])}if(E.showHorizontalLine){E.shapeRenderer.draw(z,[[0,C.y],[z.canvas.width,C.y]])}var G=d(A,C.x,C.y);if(E.showCursorLegend){var r=j(A.targetId+" td.jqplot-cursor-legend-label");for(var B=0;B0;r--){s=v[r-1];if(q[s].show){u[s]=q[s].series_p2u(w[s.charAt(0)])}}return{offsets:t,gridPos:w,dataPos:u}}function h(z){var x=z.data.plot;var y=x.plugins.cursor;if(y.show&&y.zoom&&y._zoom.started&&!y.zoomTarget){z.preventDefault();var B=y.zoomCanvas._ctx;var v=o(z);var w=v.gridPos;var t=v.dataPos;y._zoom.gridpos=w;y._zoom.datapos=t;y._zoom.zooming=true;var u=w.x;var s=w.y;var A=B.canvas.height;var q=B.canvas.width;if(y.showTooltip&&!y.onGrid&&y.showTooltipOutsideZoom){e(w,t,x);if(y.followMouse){n(w,x)}}if(y.constrainZoomTo=="x"){y._zoom.end=[u,A]}else{if(y.constrainZoomTo=="y"){y._zoom.end=[q,s]}else{y._zoom.end=[u,s]}}var r=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(r&&!r().isCollapsed){r().collapse()}}l.call(y);B=null}}function a(w,s,r,x,t){var v=t.plugins.cursor;if(t.plugins.mobile){j(document).one("vmouseup.jqplot_cursor",{plot:t},p)}else{j(document).one("mouseup.jqplot_cursor",{plot:t},p)}var u=t.axes;if(document.onselectstart!=undefined){v._oldHandlers.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!=undefined){v._oldHandlers.ondrag=document.ondrag;document.ondrag=function(){return false}}if(document.onmousedown!=undefined){v._oldHandlers.onmousedown=document.onmousedown;document.onmousedown=function(){return false}}if(v.zoom){if(!v.zoomProxy){var y=v.zoomCanvas._ctx;y.clearRect(0,0,y.canvas.width,y.canvas.height);y=null}if(v.constrainZoomTo=="x"){v._zoom.start=[s.x,0]}else{if(v.constrainZoomTo=="y"){v._zoom.start=[0,s.y]}else{v._zoom.start=[s.x,s.y]}}v._zoom.started=true;for(var q in r){v._zoom.axes.start[q]=r[q]}if(t.plugins.mobile){j(document).bind("vmousemove.jqplotCursor",{plot:t},h)}else{j(document).bind("mousemove.jqplotCursor",{plot:t},h)}}}function p(y){var v=y.data.plot;var x=v.plugins.cursor;if(x.zoom&&x._zoom.zooming&&!x.zoomTarget){var u=x._zoom.gridpos.x;var r=x._zoom.gridpos.y;var t=x._zoom.datapos;var z=x.zoomCanvas._ctx.canvas.height;var q=x.zoomCanvas._ctx.canvas.width;var w=v.axes;if(x.constrainOutsideZoom&&!x.onGrid){if(u<0){u=0}else{if(u>q){u=q}}if(r<0){r=0}else{if(r>z){r=z}}for(var s in t){if(t[s]){if(s.charAt(0)=="x"){t[s]=w[s].series_p2u(u)}else{t[s]=w[s].series_p2u(r)}}}}if(x.constrainZoomTo=="x"){r=z}else{if(x.constrainZoomTo=="y"){u=q}}x._zoom.end=[u,r];x._zoom.gridpos={x:u,y:r};x.doZoom(x._zoom.gridpos,t,v,x)}x._zoom.started=false;x._zoom.zooming=false;j(document).unbind("mousemove.jqplotCursor",h);if(document.onselectstart!=undefined&&x._oldHandlers.onselectstart!=null){document.onselectstart=x._oldHandlers.onselectstart;x._oldHandlers.onselectstart=null}if(document.ondrag!=undefined&&x._oldHandlers.ondrag!=null){document.ondrag=x._oldHandlers.ondrag;x._oldHandlers.ondrag=null}if(document.onmousedown!=undefined&&x._oldHandlers.onmousedown!=null){document.onmousedown=x._oldHandlers.onmousedown;x._oldHandlers.onmousedown=null}}function l(){var y=this._zoom.start;var u=this._zoom.end;var s=this.zoomCanvas._ctx;var r,v,x,q;if(u[0]>y[0]){r=y[0];q=u[0]-y[0]}else{r=u[0];q=y[0]-u[0]}if(u[1]>y[1]){v=y[1];x=u[1]-y[1]}else{v=u[1];x=y[1]-u[1]}s.fillStyle="rgba(0,0,0,0.2)";s.strokeStyle="#999999";s.lineWidth=1;s.clearRect(0,0,s.canvas.width,s.canvas.height);s.fillRect(0,0,s.canvas.width,s.canvas.height);s.clearRect(r,v,q,x);s.strokeRect(r,v,q,x);s=null}j.jqplot.CursorLegendRenderer=function(q){j.jqplot.TableLegendRenderer.call(this,q);this.formatString="%s"};j.jqplot.CursorLegendRenderer.prototype=new j.jqplot.TableLegendRenderer();j.jqplot.CursorLegendRenderer.prototype.constructor=j.jqplot.CursorLegendRenderer;j.jqplot.CursorLegendRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var w=this._series,A;var r=document.createElement("table");this._elem=j(r);r=null;this._elem.addClass("jqplot-legend jqplot-cursor-legend");this._elem.css("position","absolute");var q=false;for(var x=0;x').appendTo(this._elem);E.data("seriesIndex",s);j('
    ').appendTo(E);var G=j('');G.appendTo(E);G.data("seriesIndex",s);if(this.escapeHtml){G.text(D)}else{G.html(D)}E=null;G=null}return this._elem}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js new file mode 100644 index 000000000..741780150 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(h){h.jqplot.DateAxisRenderer=function(){h.jqplot.LinearAxisRenderer.call(this);this.date=new h.jsDate()};var c=1000;var e=60*c;var f=60*e;var l=24*f;var b=7*l;var j=30.4368499*l;var k=365.242199*l;var g=[31,28,31,30,31,30,31,30,31,30,31,30];var i=["%M:%S.%#N","%M:%S.%#N","%M:%S.%#N","%M:%S","%M:%S","%M:%S","%M:%S","%H:%M:%S","%H:%M:%S","%H:%M","%H:%M","%H:%M","%H:%M","%H:%M","%H:%M","%a %H:%M","%a %H:%M","%b %e %H:%M","%b %e %H:%M","%b %e %H:%M","%b %e %H:%M","%v","%v","%v","%v","%v","%v","%v"];var m=[0.1*c,0.2*c,0.5*c,c,2*c,5*c,10*c,15*c,30*c,e,2*e,5*e,10*e,15*e,30*e,f,2*f,4*f,6*f,8*f,12*f,l,2*l,3*l,4*l,5*l,b,2*b];var d=[];function a(p,s,t){var o=Number.MAX_VALUE;var u,r,v;for(var q=0,n=m.length;qC.max)||C.max==null){C.max=y[r][0]}if(r>0){o=Math.abs(y[r][0]-y[r-1][0]);u.intervals.push(o);if(u.frequencies.hasOwnProperty(o)){u.frequencies[o]+=1}else{u.frequencies[o]=1}}x+=o}else{y[r][1]=new h.jsDate(y[r][1]).getTime();A[r][1]=new h.jsDate(y[r][1]).getTime();z[r][1]=new h.jsDate(y[r][1]).getTime();if((y[r][1]!=null&&y[r][1]C.max)||C.max==null){C.max=y[r][1]}if(r>0){o=Math.abs(y[r][1]-y[r-1][1]);u.intervals.push(o);if(u.frequencies.hasOwnProperty(o)){u.frequencies[o]+=1}else{u.frequencies[o]=1}}}x+=o}if(D.renderer.bands){if(D.renderer.bands.hiData.length){var w=D.renderer.bands.hiData;for(var r=0,q=w.length;rC.max)||C.max==null){C.max=w[r][0]}}else{w[r][1]=new h.jsDate(w[r][1]).getTime();if((w[r][1]!=null&&w[r][1]>C.max)||C.max==null){C.max=w[r][1]}}}}if(D.renderer.bands.lowData.length){var w=D.renderer.bands.lowData;for(var r=0,q=w.length;r6){D=6}}var V=new h.jsDate(ae).setDate(1).setHours(0,0,0,0);var q=new h.jsDate(J);var z=new h.jsDate(J).setDate(1).setHours(0,0,0,0);if(q.getTime()!==z.getTime()){z=z.add(1,"month")}var S=z.diff(V,"month");ab=Math.ceil(S/D)+1;this.min=V.getTime();this.max=V.clone().add((ab-1)*D,"month").getTime();this.numberTicks=ab;for(var aa=0;aa200){this.numberTicks=parseInt(3+(n-200)/100,10)}else{this.numberTicks=2}}}O=B/(this.numberTicks-1)/1000;if(this.daTickInterval==null){this.daTickInterval=[O,"seconds"]}for(var aa=0;aa570)?n[o]*0.8:n[o]+0.3*(255-n[o]);n[o]=parseInt(n[o],10)}this.highlightColors.push("rgb("+n[0]+","+n[1]+","+n[2]+")")}}t.postParseOptionsHooks.addOnce(l);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",b);t.eventListenerHooks.addOnce("jqplotMouseDown",a);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",m);t.postDrawHooks.addOnce(h)};e.jqplot.DonutRenderer.prototype.setGridData=function(s){var o=[];var t=[];var n=this.startAngle/180*Math.PI;var r=0;this._drawData=false;for(var q=0;q0){o[q]+=o[q-1]}r+=this.data[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q0){o[q]+=o[q-1]}r+=s[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q6.282+this.startAngle){t=6.282+this.startAngle;if(u>t){u=6.281+this.startAngle}}if(u>=t){return}x.beginPath();x.fillStyle=p;x.strokeStyle=p;x.arc(0,0,n,u,t,false);x.lineTo(v*Math.cos(t),v*Math.sin(t));x.arc(0,0,v,t,u,true);x.closePath();if(w){x.fill()}else{x.stroke()}}if(s){for(var q=0;q1&&this.index>0)?this._previousSeries[0]._diameter:this._diameter;this._thickness=this.thickness||(M-this.innerDiameter-2*X*this._numberSeries)/this._numberSeries/2}else{this._thickness=this.thickness||v/2/(this._numberSeries+1)*0.85}var K=this._radius=this._diameter/2;this._innerRadius=this._radius-this._thickness;var o=this.startAngle/180*Math.PI;this._center=[(s-u*q)/2+u*q,(H-u*p)/2+u*p];if(this.shadow){var L="rgba(0,0,0,"+this.shadowAlpha+")";for(var Q=0;Q=this.dataLabelThreshold){var S,U=(A+z)/2,C;if(this.dataLabels=="label"){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,V[Q][0])}else{if(this.dataLabels=="value"){S=this.dataLabelFormatString||"%d";C=e.jqplot.sprintf(S,this.data[Q][1])}else{if(this.dataLabels=="percent"){S=this.dataLabelFormatString||"%d%%";C=e.jqplot.sprintf(S,V[Q][2]*100)}else{if(this.dataLabels.constructor==Array){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,this.dataLabels[Q])}}}}var n=this._innerRadius+this._thickness*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var F=this._center[0]+Math.cos(U)*n+this.canvas._offsets.left;var E=this._center[1]+Math.sin(U)*n+this.canvas._offsets.top;var D=e(''+C+"").insertBefore(P.eventCanvas._elem);F-=D.width()/2;E-=D.height()/2;F=Math.round(F);E=Math.round(E);D.css({left:F,top:E})}}};e.jqplot.DonutAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.DonutAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.DonutAxisRenderer.prototype.constructor=e.jqplot.DonutAxisRenderer;e.jqplot.DonutAxisRenderer.prototype.init=function(n){this.tickRenderer=e.jqplot.DonutTickRenderer;e.extend(true,this,n);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.DonutLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.DonutLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.DonutLegendRenderer.prototype.constructor=e.jqplot.DonutLegendRenderer;e.jqplot.DonutLegendRenderer.prototype.init=function(n){this.numberRows=null;this.numberColumns=null;e.extend(true,this,n)};e.jqplot.DonutLegendRenderer.prototype.draw=function(){var q=this;if(this.show){var y=this._series;var B="position:absolute;";B+=(this.background)?"background:"+this.background+";":"";B+=(this.border)?"border:"+this.border+";":"";B+=(this.fontSize)?"font-size:"+this.fontSize+";":"";B+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";B+=(this.textColor)?"color:"+this.textColor+";":"";B+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";B+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";B+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";B+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('
    ');var F=false,x=false,n,v;var z=y[0];var o=new e.jqplot.ColorGenerator(z.seriesColors);if(z.show){var G=z.data;if(this.numberRows){n=this.numberRows;if(!this.numberColumns){v=Math.ceil(G.length/n)}else{v=this.numberColumns}}else{if(this.numberColumns){v=this.numberColumns;n=Math.ceil(G.length/this.numberColumns)}else{n=G.length;v=1}}var E,D,p,t,r,u,w,C;var A=0;for(E=0;E').prependTo(this._elem)}else{p=e('').appendTo(this._elem)}for(D=0;D0){F=true}else{F=false}}else{if(E==n-1){F=false}else{F=true}}w=(F)?this.rowSpacing:"0";t=e('
    ');r=e('');if(this.escapeHtml){r.text(u)}else{r.html(u)}if(x){r.prependTo(p);t.prependTo(p)}else{t.appendTo(p);r.appendTo(p)}F=true}A++}}}}return this._elem};function c(r,q,o){o=o||{};o.axesDefaults=o.axesDefaults||{};o.legend=o.legend||{};o.seriesDefaults=o.seriesDefaults||{};var n=false;if(o.seriesDefaults.renderer==e.jqplot.DonutRenderer){n=true}else{if(o.series){for(var p=0;p=0.6)?l[3]*0.6:l[3]*(2-l[3]);m.color="rgba("+o[0]+","+o[1]+","+o[2]+","+k+")"}i.color=m.color;i.init();var g=(p.pointIndex>0)?p.pointIndex-1:0;var j=p.pointIndex+2;m._gridData=q.gridData.slice(g,j)}function e(o,l,h,t,m){if(m.plugins.dragable.dragCanvas.isDragging){var u=m.plugins.dragable.dragCanvas;var i=u._neighbor;var w=m.series[i.seriesIndex];var k=w.plugins.dragable;var r=w.gridData;var p=(k.constrainTo=="y")?i.gridData[0]:l.x;var n=(k.constrainTo=="x")?i.gridData[1]:l.y;var g=w._xaxis.series_p2u(p);var q=w._yaxis.series_p2u(n);var v=u._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);if(i.pointIndex>0){k._gridData[1]=[p,n]}else{k._gridData[0]=[p,n]}m.series[i.seriesIndex].draw(u._ctx,{gridData:k._gridData,shadow:false,preventJqPlotSeriesDrawTrigger:true,color:k.color,markerOptions:{color:k.color,shadow:false},trendline:{show:false}});m.target.trigger("jqplotSeriesPointChange",[i.seriesIndex,i.pointIndex,[g,q],[p,n]])}else{if(t!=null){var j=m.series[t.seriesIndex];if(j.isDragable){var u=m.plugins.dragable.dragCanvas;if(!u.isOver){u._cursors.push(o.target.style.cursor);o.target.style.cursor="pointer"}u.isOver=true}}else{if(t==null){var u=m.plugins.dragable.dragCanvas;if(u.isOver){o.target.style.cursor=u._cursors.pop();u.isOver=false}}}}}function c(k,i,g,l,j){var m=j.plugins.dragable.dragCanvas;m._cursors.push(k.target.style.cursor);if(l!=null){var o=j.series[l.seriesIndex];var h=o.plugins.dragable;if(o.isDragable&&!m.isDragging){m._neighbor=l;m.isDragging=true;f(j,l);h.markerRenderer.draw(o.gridData[l.pointIndex][0],o.gridData[l.pointIndex][1],m._ctx);k.target.style.cursor="move";j.target.trigger("jqplotDragStart",[l.seriesIndex,l.pointIndex,i,g])}}else{var n=m._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);m.isDragging=false}}function a(m,j,g,o,k){if(k.plugins.dragable.dragCanvas.isDragging){var p=k.plugins.dragable.dragCanvas;var q=p._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);p.isDragging=false;var h=p._neighbor;var r=k.series[h.seriesIndex];var i=r.plugins.dragable;var n=(i.constrainTo=="y")?h.data[0]:g[r.xaxis];var l=(i.constrainTo=="x")?h.data[1]:g[r.yaxis];r.data[h.pointIndex][0]=n;r.data[h.pointIndex][1]=l;k.drawSeries({preventJqPlotSeriesDrawTrigger:true},h.seriesIndex);p._neighbor=null;m.target.style.cursor=p._cursors.pop();k.target.trigger("jqplotDragStop",[j,g])}}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js new file mode 100644 index 000000000..968e77cd0 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(c){c.jqplot.EnhancedLegendRenderer=function(){c.jqplot.TableLegendRenderer.call(this)};c.jqplot.EnhancedLegendRenderer.prototype=new c.jqplot.TableLegendRenderer();c.jqplot.EnhancedLegendRenderer.prototype.constructor=c.jqplot.EnhancedLegendRenderer;c.jqplot.EnhancedLegendRenderer.prototype.init=function(d){this.numberRows=null;this.numberColumns=null;this.seriesToggle="normal";this.seriesToggleReplot=false;this.disableIEFading=true;c.extend(true,this,d);if(this.seriesToggle){c.jqplot.postDrawHooks.push(b)}};c.jqplot.EnhancedLegendRenderer.prototype.draw=function(m,y){var f=this;if(this.show){var r=this._series;var u;var w="position:absolute;";w+=(this.background)?"background:"+this.background+";":"";w+=(this.border)?"border:"+this.border+";":"";w+=(this.fontSize)?"font-size:"+this.fontSize+";":"";w+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";w+=(this.textColor)?"color:"+this.textColor+";":"";w+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";w+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";w+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";w+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=c('
    ');if(this.seriesToggle){this._elem.css("z-index","3")}var C=false,q=false,d,o;if(this.numberRows){d=this.numberRows;if(!this.numberColumns){o=Math.ceil(r.length/d)}else{o=this.numberColumns}}else{if(this.numberColumns){o=this.numberColumns;d=Math.ceil(r.length/this.numberColumns)}else{d=r.length;o=1}}var B,z,e,l,k,n,p,t,h,g;var v=0;for(B=r.length-1;B>=0;B--){if(o==1&&r[B]._stack||r[B].renderer.constructor==c.jqplot.BezierCurveRenderer){q=true}}for(B=0;B0){C=true}else{C=false}}else{if(B==d-1){C=false}else{C=true}}p=(C)?this.rowSpacing:"0";l=c(document.createElement("td"));l.addClass("jqplot-table-legend jqplot-table-legend-swatch");l.css({textAlign:"center",paddingTop:p});h=c(document.createElement("div"));h.addClass("jqplot-table-legend-swatch-outline");g=c(document.createElement("div"));g.addClass("jqplot-table-legend-swatch");g.css({backgroundColor:x,borderColor:x});l.append(h.append(g));k=c(document.createElement("td"));k.addClass("jqplot-table-legend jqplot-table-legend-label");k.css("paddingTop",p);if(this.escapeHtml){k.text(n)}else{k.html(n)}if(q){if(this.showLabels){k.prependTo(e)}if(this.showSwatches){l.prependTo(e)}}else{if(this.showSwatches){l.appendTo(e)}if(this.showLabels){k.appendTo(e)}}if(this.seriesToggle){var A;if(typeof(this.seriesToggle)==="string"||typeof(this.seriesToggle)==="number"){if(!c.jqplot.use_excanvas||!this.disableIEFading){A=this.seriesToggle}}if(this.showSwatches){l.bind("click",{series:u,speed:A,plot:y,replot:this.seriesToggleReplot},a);l.addClass("jqplot-seriesToggle")}if(this.showLabels){k.bind("click",{series:u,speed:A,plot:y,replot:this.seriesToggleReplot},a);k.addClass("jqplot-seriesToggle")}if(!u.show&&u.showLabel){l.addClass("jqplot-series-hidden");k.addClass("jqplot-series-hidden")}}C=true}}v++}l=k=h=g=null}}return this._elem};var a=function(j){var i=j.data,m=i.series,k=i.replot,h=i.plot,f=i.speed,l=m.index,g=false;if(m.canvas._elem.is(":hidden")||!m.show){g=true}var e=function(){if(k){var n={};if(c.isPlainObject(k)){c.extend(true,n,k)}h.replot(n);if(g&&f){var d=h.series[l];if(d.shadowCanvas._elem){d.shadowCanvas._elem.hide().fadeIn(f)}d.canvas._elem.hide().fadeIn(f);d.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+d.index).hide().fadeIn(f)}}else{var d=h.series[l];if(d.canvas._elem.is(":hidden")||!d.show){if(typeof h.options.legend.showSwatches==="undefined"||h.options.legend.showSwatches===true){h.legend._elem.find("td").eq(l*2).addClass("jqplot-series-hidden")}if(typeof h.options.legend.showLabels==="undefined"||h.options.legend.showLabels===true){h.legend._elem.find("td").eq((l*2)+1).addClass("jqplot-series-hidden")}}else{if(typeof h.options.legend.showSwatches==="undefined"||h.options.legend.showSwatches===true){h.legend._elem.find("td").eq(l*2).removeClass("jqplot-series-hidden")}if(typeof h.options.legend.showLabels==="undefined"||h.options.legend.showLabels===true){h.legend._elem.find("td").eq((l*2)+1).removeClass("jqplot-series-hidden")}}}};m.toggleDisplay(j,e)};var b=function(){if(this.legend.renderer.constructor==c.jqplot.EnhancedLegendRenderer&&this.legend.seriesToggle){var d=this.legend._elem.detach();this.eventCanvas._elem.after(d)}}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.funnelRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.funnelRenderer.min.js new file mode 100644 index 000000000..af0dabac2 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.funnelRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(e){e.jqplot.FunnelRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.FunnelRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.FunnelRenderer.prototype.constructor=e.jqplot.FunnelRenderer;e.jqplot.FunnelRenderer.prototype.init=function(p,t){this.padding={top:20,right:20,bottom:20,left:20};this.sectionMargin=6;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.widthRatio=0.2;this.lineWidth=2;this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this._type="funnel";this.tickRenderer=e.jqplot.FunnelTickRenderer;if(p.highlightMouseDown&&p.highlightMouseOver==null){p.highlightMouseOver=false}e.extend(true,this,p);this._highlightedPoint=null;this._bases=[];this._atot;this._areas=[];this._lengths=[];this._angle;this._dataIndices=[];this._unorderedData=e.extend(true,[],this.data);var o=e.extend(true,[],this.data);for(var r=0;r570)?m[n]*0.8:m[n]+0.4*(255-m[n]);m[n]=parseInt(m[n],10)}this.highlightColors.push("rgb("+m[0]+","+m[1]+","+m[2]+")")}}t.postParseOptionsHooks.addOnce(k);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};e.jqplot.FunnelRenderer.prototype.setGridData=function(o){var n=0;var p=[];for(var m=0;mthis._lengths[Y]*n&&W<100){this._lengths[Y]=this._areas[Y]/(this._bases[Y]-this._lengths[Y]*Math.tan(this._angle));aa=Math.abs(this._lengths[Y]-E);this._bases[Y+1]=this._bases[Y]-(2*this._lengths[Y]*Math.tan(this._angle));E=this._lengths[Y];W++}Q+=this._lengths[Y]}this._vertices=new Array(B.length);var ae=[t,F],ad=[t+this._bases[0],F],ac=[t+(this._bases[0]-this._bases[this._bases.length-1])/2,F+this._length],ab=[ac[0]+this._bases[this._bases.length-1],ac[1]];function V(ag){var x=(ae[1]-ac[1])/(ae[0]-ac[0]);var v=ae[1]-x*ae[0];var ah=ag+ae[1];return[(ah-v)/x,ah]}function D(ag){var x=(ad[1]-ab[1])/(ad[0]-ab[0]);var v=ad[1]-x*ad[0];var ah=ag+ad[1];return[(ah-v)/x,ah]}var T=w,S=u;var Z=0,m=0;for(Y=0;Y0&&Y0&&Y=this.dataLabelThreshold){var K,X;if(this.dataLabels=="label"){K=this.dataLabelFormatString||"%s";X=e.jqplot.sprintf(K,B[Y][0])}else{if(this.dataLabels=="value"){K=this.dataLabelFormatString||"%d";X=e.jqplot.sprintf(K,this.data[Y][1])}else{if(this.dataLabels=="percent"){K=this.dataLabelFormatString||"%d%%";X=e.jqplot.sprintf(K,B[Y][1]*100)}else{if(this.dataLabels.constructor==Array){K=this.dataLabelFormatString||"%s";X=e.jqplot.sprintf(K,this.dataLabels[this._dataIndices[Y]])}}}}var s=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var T=(U[0][0]+U[1][0])/2+this.canvas._offsets.left;var S=(U[1][1]+U[2][1])/2+this.canvas._offsets.top;var z=e(''+X+"").insertBefore(p.eventCanvas._elem);T-=z.width()/2;S-=z.height()/2;T=Math.round(T);S=Math.round(S);z.css({left:T,top:S})}}};e.jqplot.FunnelAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.FunnelAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.FunnelAxisRenderer.prototype.constructor=e.jqplot.FunnelAxisRenderer;e.jqplot.FunnelAxisRenderer.prototype.init=function(m){this.tickRenderer=e.jqplot.FunnelTickRenderer;e.extend(true,this,m);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.FunnelLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.FunnelLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.FunnelLegendRenderer.prototype.constructor=e.jqplot.FunnelLegendRenderer;e.jqplot.FunnelLegendRenderer.prototype.init=function(m){this.numberRows=null;this.numberColumns=null;e.extend(true,this,m)};e.jqplot.FunnelLegendRenderer.prototype.draw=function(){var p=this;if(this.show){var x=this._series;var A="position:absolute;";A+=(this.background)?"background:"+this.background+";":"";A+=(this.border)?"border:"+this.border+";":"";A+=(this.fontSize)?"font-size:"+this.fontSize+";":"";A+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";A+=(this.textColor)?"color:"+this.textColor+";":"";A+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";A+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";A+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";A+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('
    ');var E=false,w=false,m,u;var y=x[0];var n=new e.jqplot.ColorGenerator(y.seriesColors);if(y.show){var F=y.data;if(this.numberRows){m=this.numberRows;if(!this.numberColumns){u=Math.ceil(F.length/m)}else{u=this.numberColumns}}else{if(this.numberColumns){u=this.numberColumns;m=Math.ceil(F.length/this.numberColumns)}else{m=F.length;u=1}}var D,C,o,r,q,t,v,B;var z=0;for(D=0;D').prependTo(this._elem)}else{o=e('').appendTo(this._elem)}for(C=0;C0){E=true}else{E=false}}else{if(D==m-1){E=false}else{E=true}}v=(E)?this.rowSpacing:"0";r=e('
    ');q=e('');if(this.escapeHtml){q.text(t)}else{q.html(t)}if(w){q.prependTo(o);r.prependTo(o)}else{r.appendTo(o);q.appendTo(o)}E=true}z++}}}}return this._elem};function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.legend=n.legend||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==e.jqplot.FunnelRenderer){m=true}else{if(n.series){for(var o=0;o=0.6)?l[3]*0.6:l[3]*(2-l[3]);i.color="rgba("+n[0]+","+n[1]+","+n[2]+","+k+")";i.init();i.draw(p.gridData[o.pointIndex][0],p.gridData[o.pointIndex][1],j.highlightCanvas._ctx)}function g(A,q,m){var k=A.plugins.highlighter;var D=k._tooltipElem;var r=q.highlighter||{};var t=d.extend(true,{},k,r);if(t.useAxesFormatters){var w=q._xaxis._ticks[0].formatter;var h=q._yaxis._ticks[0].formatter;var E=q._xaxis._ticks[0].formatString;var s=q._yaxis._ticks[0].formatString;var z;var u=w(E,m.data[0]);var l=[];for(var B=1;B140){h=Math.round(Math.log(this.max/this.min)/Math.log(this.base)+1);if(h<2){h=2}if(C===0){var o=b/(h-1);if(o<100){C=0}else{if(o<190){C=1}else{if(o<250){C=3}else{if(o<600){C=4}else{C=9}}}}}}else{h=2;if(C===0){C=1}C=0}}else{h=this.numberTicks}if(E>=0&&C!==3){this._autoFormatString="%d"}else{if(E<=0&&C===3){var o=-(E-1);this._autoFormatString="%."+Math.abs(E-1)+"f"}else{if(E<0){var o=-E;this._autoFormatString="%."+Math.abs(E)+"f"}else{this._autoFormatString="%d"}}}var O,H,z,p,n,k;for(var K=0;K=0;J--){z=p-k*(J+1);H=new this.tickRenderer(this.tickOptions);if(this._overrideFormatString&&this._autoFormatString!=""){H.formatString=this._autoFormatString}if(!this.showTicks){H.showLabel=false;H.showMark=false}else{if(!this.showTickMarks){H.showMark=false}}H.setTick(z,this.name);this._ticks.push(H)}}}}else{if(this.min!=null&&this.max!=null){var y=a.extend(true,{},this.tickOptions,{name:this.name,value:null});var I,e;if(this.numberTicks==null&&this.tickInterval==null){var D=Math.max(b,g+1);var L=Math.ceil((D-g)/35+1);var B=a.jqplot.LinearTickGenerator.bestConstrainedInterval(this.min,this.max,L);this._autoFormatString=B[3];I=B[2];e=B[4];for(var K=0;K0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"middle":c=-n.getHeight()/2;break;default:c=-n.getHeight()/2;break}}else{c=-n.getHeight()/2}var z=this.u2p(n.value)+c+"px";n._elem.css("top",z);n.pack()}}if(o){var x=this._label._elem.outerHeight(true);this._label._elem.css("top",m-g/2-x/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js new file mode 100644 index 000000000..7969de739 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(a){a.jqplot.MekkoAxisRenderer=function(){};a.jqplot.MekkoAxisRenderer.prototype.init=function(c){this.tickMode;this.barLabelRenderer=a.jqplot.AxisLabelRenderer;this.barLabels=this.barLabels||[];this.barLabelOptions={};this.tickOptions=a.extend(true,{showGridline:false},this.tickOptions);this._barLabels=[];a.extend(true,this,c);if(this.name=="yaxis"){this.tickOptions.formatString=this.tickOptions.formatString||"%d%"}var b=this._dataBounds;b.min=0;if(this.name=="yaxis"||this.name=="y2axis"){b.max=100;this.tickMode="even"}else{if(this.name=="xaxis"){this.tickMode=(this.tickMode==null)?"bar":this.tickMode;for(var d=0;dk){k=d}}}if(b){c=this._label._elem.outerWidth(true);j=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){k=k+j;this._elem.css({height:k+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){k=k+j;this._elem.css({height:k+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){k=k+c;this._elem.css({width:k+"px",left:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}else{k=k+c;this._elem.css({width:k+"px",right:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}}}}};a.jqplot.MekkoAxisRenderer.prototype.createTicks=function(){var z=this._ticks;var w=this.ticks;var B=this.name;var y=this._dataBounds;var p,x;var n,r;var d,c;var h,b,s,q;if(w.length){for(s=0;s0){g=Math.max(Math.log(n)/Math.LN10,0.05)}n-=g;r+=g}var k=r-n;var m,o;var v,l,u;var f=[3,5,6,11,21];if(this.name=="yaxis"||this.name=="y2axis"){this.min=0;this.max=100;if(!this.numberTicks){if(this.tickInterval){this.numberTicks=3+Math.ceil(k/this.tickInterval)}else{v=2+Math.ceil((p-(this.tickSpacing-1))/this.tickSpacing);for(s=0;s1){l=u;continue}else{if(u<1){if(Math.abs(l-1)v){h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(this.max,this.name);this._ticks.push(h)}}else{if(this.tickMode=="even"){this.min=0;this.max=this.max||y.max;var A=2+Math.ceil((p-(this.tickSpacing-1))/this.tickSpacing);k=this.max-this.min;this.numberTicks=A;this.tickInterval=k/(this.numberTicks-1);for(s=0;s0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"middle":c=-n.getHeight()/2;break;default:c=-n.getHeight()/2;break}}else{c=-n.getHeight()/2}var D=this.u2p(n.value)+c+"px";n._elem.css("top",D);n.pack()}}if(o){var z=this._label._elem.outerHeight(true);this._label._elem.css("top",m-f/2-z/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.mekkoRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.mekkoRenderer.min.js new file mode 100644 index 000000000..18dc3a12b --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.mekkoRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(b){b.jqplot.MekkoRenderer=function(){this.shapeRenderer=new b.jqplot.ShapeRenderer();this.borderColor=null;this.showBorders=true};b.jqplot.MekkoRenderer.prototype.init=function(c,e){this.fill=false;this.fillRect=true;this.strokeRect=true;this.shadow=false;this._xwidth=0;this._xstart=0;b.extend(true,this.renderer,c);var d={lineJoin:"miter",lineCap:"butt",isarc:false,fillRect:this.fillRect,strokeRect:this.strokeRect};this.renderer.shapeRenderer.init(d);e.axes.x2axis._series.push(this);this._type="mekko"};b.jqplot.MekkoRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var c=this._yaxis.series_u2p;var g=this._plotData;this.gridData=[];this._xwidth=e(this._sumy)-e(0);if(this.index>0){this._xstart=h.series[this.index-1]._xstart+h.series[this.index-1]._xwidth}var l=this.canvas.getHeight();var d=0;var k;var j;for(var f=0;f');var w=false,n=true,c,l;var p=o[0];var d=new b.jqplot.ColorGenerator(p.seriesColors);if(p.show){var x=p.data;if(this.numberRows){c=this.numberRows;if(!this.numberColumns){l=Math.ceil(x.length/c)}else{l=this.numberColumns}}else{if(this.numberColumns){l=this.numberColumns;c=Math.ceil(x.length/this.numberColumns)}else{c=x.length;l=1}}var v,u,e,h,g,k,m,t;var q=0;for(v=0;v').prependTo(this._elem)}else{e=b('').appendTo(this._elem)}for(u=0;u0){w=true}else{w=false}}else{if(v==c-1){w=false}else{w=true}}m=(w)?this.rowSpacing:"0";h=b('
    ');g=b('');if(this.escapeHtml){g.text(k)}else{g.html(k)}if(n){g.prependTo(e);h.prependTo(e)}else{h.appendTo(e);g.appendTo(e)}w=true}q++}}e=null;h=null;g=null}}return this._elem};b.jqplot.MekkoLegendRenderer.prototype.pack=function(f){if(this.show){var e={_top:f.top,_left:f.left,_right:f.right,_bottom:this._plotDimensions.height-f.bottom};if(this.placement=="insideGrid"){switch(this.location){case"nw":var d=e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"ne":var d=f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({right:d,top:c});break;case"e":var d=f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;case"se":var d=f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"sw":var d=e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"w":var d=e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}else{switch(this.location){case"nw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("right",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-e._top+this.yoffset;this._elem.css("left",d);this._elem.css("bottom",c);break;case"ne":var d=this._plotDimensions.width-f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({left:d,top:c});break;case"e":var d=this._plotDimensions.width-f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;case"se":var d=this._plotDimensions.width-f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-f.bottom+this.yoffset;this._elem.css({left:d,top:c});break;case"sw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"w":var d=this._plotDimensions.width-e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}}};function a(g,f,d){d=d||{};d.axesDefaults=d.axesDefaults||{};d.legend=d.legend||{};d.seriesDefaults=d.seriesDefaults||{};var c=false;if(d.seriesDefaults.renderer==b.jqplot.MekkoRenderer){c=true}else{if(d.series){for(var e=0;e=this.data[0][1]){this.max=this.intervals[this.intervals.length-1][0];this.setmax=false}}else{this.setmax=false}}else{this.min=(this.min==null)?0:this.min;this.setmin=false;if(this.max==null){this.max=this.data[0][1]*1.25;this.setmax=true}else{this.setmax=false}}}};c.jqplot.MeterGaugeRenderer.prototype.setGridData=function(j){var f=[];var k=[];var e=this.startAngle;for(var h=0;h0){f[h]+=f[h-1]}}var g=Math.PI*2/f[f.length-1];for(var h=0;h0){f[h]+=f[h-1]}}var g=Math.PI*2/f[f.length-1];for(var h=0;h=0;h--){e=f/(j[h]*Math.pow(10,g));if(e==4||e==5){return e-1}}return null}c.jqplot.MeterGaugeRenderer.prototype.draw=function(X,aC,ap){var aa;var aM=(ap!=undefined)?ap:{};var ai=0;var ah=0;var at=1;if(ap.legendInfo&&ap.legendInfo.placement=="inside"){var aI=ap.legendInfo;switch(aI.location){case"nw":ai=aI.width+aI.xoffset;break;case"w":ai=aI.width+aI.xoffset;break;case"sw":ai=aI.width+aI.xoffset;break;case"ne":ai=aI.width+aI.xoffset;at=-1;break;case"e":ai=aI.width+aI.xoffset;at=-1;break;case"se":ai=aI.width+aI.xoffset;at=-1;break;case"n":ah=aI.height+aI.yoffset;break;case"s":ah=aI.height+aI.yoffset;at=-1;break;default:break}}if(this.label){this._labelElem=c('
    '+this.label+"
    ");this.canvas._elem.after(this._labelElem)}var m=(aM.shadow!=undefined)?aM.shadow:this.shadow;var N=(aM.showLine!=undefined)?aM.showLine:this.showLine;var I=(aM.fill!=undefined)?aM.fill:this.fill;var K=X.canvas.width;var S=X.canvas.height;if(this.padding==null){this.padding=Math.round(Math.min(K,S)/30)}var Q=K-ai-2*this.padding;var ab=S-ah-2*this.padding;if(this.labelPosition=="bottom"&&this.label){ab-=this._labelElem.outerHeight(true)}var L=Math.min(Q,ab);var ad=L;if(!this.diameter){if(this.semiCircular){if(Q>=2*ab){if(!this.ringWidth){this.ringWidth=2*ab/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=this.ringWidth/2+this.needleThickness/2+this.needlePad;this.diameter=2*(ab-2*this.innerPad)}else{if(!this.ringWidth){this.ringWidth=Q/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=this.ringWidth/2+this.needleThickness/2+this.needlePad;this.diameter=Q-2*this.innerPad-this.ringWidth-this.padding}this._center=[(K-at*ai)/2+at*ai,(S+at*ah-this.padding-this.ringWidth-this.innerPad)]}else{if(!this.ringWidth){this.ringWidth=ad/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=0;this.diameter=ad-this.ringWidth;this._center=[(K-at*ai)/2+at*ai,(S-at*ah)/2+at*ah]}if(this._labelElem&&this.labelPosition=="bottom"){this._center[1]-=this._labelElem.outerHeight(true)}}this._radius=this.diameter/2;this.tickSpacing=6000/this.diameter;if(!this.hubRadius){this.hubRadius=this.diameter/18}this.shadowOffset=0.5+this.ringWidth/9;this.shadowWidth=this.ringWidth*1;this.tickPadding=3+Math.pow(this.diameter/20,0.7);this.tickOuterRadius=this._radius-this.ringWidth/2-this.tickPadding;this.tickLength=(this.showTicks)?this._radius/13:0;if(this.ticks.length==0){var A=this.max,aL=this.min,q=this.setmax,aG=this.setmin,au=(A-aL)*this.tickSpacing/this.span;var aw=Math.floor(parseFloat((Math.log(au)/Math.log(10)).toFixed(11)));var an=(au/Math.pow(10,aw));(an>2&&an<=2.5)?an=2.5:an=Math.ceil(an);var T=this.tickPositions;var aA,ak;for(aa=0;aa0)?aL-aL%au:aL-aL%au-au;if(!this.forceZero){var D=Math.min(aL-aP,0.8*au);var o=Math.floor(D/T[aA]);if(o>1){aP=aP+T[aA]*(o-1);if(parseInt(aP,10)!=aP&&parseInt(aP-T[aA],10)==aP-T[aA]){aP=aP-T[aA]}}}if(aL==aP){aL-=au}else{if(aL-aP>0.23*au){aL=aP}else{aL=aP-au;ak+=1}}ak+=1;var E=aL+(ak-1)*au;if(A>=E){E+=au;ak+=1}if(E-A<0.23*au){E+=au;ak+=1}this.max=A=E;this.min=aL;this.tickInterval=au;this.numberTicks=ak;var O;for(aa=0;aa=E){A=E+au;ak+=1}else{A=E}this.tickInterval=this.tickInterval||au;this.numberTicks=this.numberTicks||ak;var O;for(aa=0;aa1){var aJ=String(P);if(aJ.search(/\./)==-1){var aF=aJ.search(/0+$/);av=(aF>0)?aJ.length-aF-1:0}}M=P/Math.pow(10,av);for(aa=0;aa'+this.ticks[aa][1]+"");this.canvas._elem.after(J);aO=J.outerWidth(true);g=J.outerHeight(true);W=this._tickPoints[aa][0]-aO*(this._tickPoints[aa][2]-Math.PI)/Math.PI-an*Math.cos(this._tickPoints[aa][2]);T=this._tickPoints[aa][1]-g/2+g/2*Math.pow(Math.abs((Math.sin(this._tickPoints[aa][2]))),0.5)+an/3*Math.pow(Math.abs((Math.sin(this._tickPoints[aa][2]))),0.5);J.css({left:W,top:T,color:this.tickColor});G=aO*Math.cos(this._tickPoints[aa][2])+g*Math.sin(Math.PI/2+this._tickPoints[aa][2]/2);n=(G>n)?G:n}}if(this.label&&this.labelPosition=="inside"){var W=this._center[0]+this.canvas._offsets.left;var an=this.tickPadding*(1-1/(this.diameter/80+1));var T=0.5*(this._center[1]+this.canvas._offsets.top-this.hubRadius)+0.5*(this._center[1]+this.canvas._offsets.top-this.tickOuterRadius+this.tickLength+an)+this.labelHeightAdjust;W-=this._labelElem.outerWidth(true)/2;T-=this._labelElem.outerHeight(true)/2;this._labelElem.css({left:W,top:T})}else{if(this.label&&this.labelPosition=="bottom"){var W=this._center[0]+this.canvas._offsets.left-this._labelElem.outerWidth(true)/2;var T=this._center[1]+this.canvas._offsets.top+this.innerPad+this.ringWidth+this.padding+this.labelHeightAdjust;this._labelElem.css({left:W,top:T})}}X.save();var ax=this.intervalInnerRadius||this.hubRadius*1.5;if(this.intervalOuterRadius==null){if(this.showTickLabels){var ag=(this.tickOuterRadius-this.tickLength-this.tickPadding-this.diameter/8)}else{var ag=(this.tickOuterRadius-this.tickLength-this.diameter/16)}}else{var ag=this.intervalOuterRadius}var P=this.max-this.min;var aD=this.intervals[this.intervals.length-1]-this.min;var y,Z,u=this.span*Math.PI/180;for(aa=0;aathis.max+R*3/this.span){ay=this.max+R*3/this.span}if(this.data[0][1]');var f=false,q=false,u,o;var w=p[0];if(w.show){var t=w.data;if(this.numberRows){u=this.numberRows;if(!this.numberColumns){o=Math.ceil(t.length/u)}else{o=this.numberColumns}}else{if(this.numberColumns){o=this.numberColumns;u=Math.ceil(t.length/this.numberColumns)}else{u=t.length;o=1}}var n,m,r,g,e,l,k,h;var v=0;for(n=0;n').prependTo(this._elem)}else{r=c('').appendTo(this._elem)}for(m=0;m0){f=true}else{f=false}}else{if(n==u-1){f=false}else{f=true}}k=(f)?this.rowSpacing:"0";g=c('
    ');e=c('');if(this.escapeHtml){e.text(l)}else{e.html(l)}if(q){e.prependTo(r);g.prependTo(r)}else{g.appendTo(r);e.appendTo(r)}f=true}v++}}}}return this._elem};function a(j,h,f){f=f||{};f.axesDefaults=f.axesDefaults||{};f.legend=f.legend||{};f.seriesDefaults=f.seriesDefaults||{};f.grid=f.grid||{};var e=false;if(f.seriesDefaults.renderer==c.jqplot.MeterGaugeRenderer){e=true}else{if(f.series){for(var g=0;gb.max||b.max==null){b.max=f[c][1]}}}else{for(var c=0;cb.max||b.max==null){b.max=f[c][2]}}}};a.jqplot.OHLCRenderer.prototype.draw=function(A,N,j){var J=this.data;var v=this._xaxis.min;var z=this._xaxis.max;var l=0;var K=J.length;var p=this._xaxis.series_u2p;var G=this._yaxis.series_u2p;var D,E,f,M,F,n,O,C;var y;var u=this.renderer;var s=(j!=undefined)?j:{};var k=(s.shadow!=undefined)?s.shadow:this.shadow;var B=(s.fill!=undefined)?s.fill:this.fill;var c=(s.fillAndStroke!=undefined)?s.fillAndStroke:this.fillAndStroke;u.bodyWidth=(s.bodyWidth!=undefined)?s.bodyWidth:u.bodyWidth;u.tickLength=(s.tickLength!=undefined)?s.tickLength:u.tickLength;A.save();if(this.show){var m,q,g,Q,t;for(var D=0;Dq){if(u.wickColor){y.color=u.wickColor}else{if(u.downBodyColor){y.color=u.downBodyColor}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,q]],f);u.shapeRenderer.draw(A,[[m,t],[m,Q]],f);y={};M=q;F=t-q;if(u.fillDownBody){y.fillRect=true}else{y.strokeRect=true;n=n-this.lineWidth;O=m-n/2}if(u.downBodyColor){y.color=u.downBodyColor;y.fillStyle=u.downBodyColor}C=[O,M,n,F]}else{if(u.wickColor){y.color=u.wickColor}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,Q]],f);y={};y.fillRect=false;y.strokeRect=false;O=[m-n/2,q];M=[m+n/2,t];n=null;F=null;C=[O,M]}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,C,f)}else{E=s.color;if(u.openColor){s.color=u.openColor}if(!u.hlc){u.shapeRenderer.draw(A,[[m-u._tickLength,q],[m,q]],s)}s.color=E;if(u.wickColor){s.color=u.wickColor}u.shapeRenderer.draw(A,[[m,g],[m,Q]],s);s.color=E;if(u.closeColor){s.color=u.closeColor}u.shapeRenderer.draw(A,[[m,t],[m+u._tickLength,t]],s);s.color=E}}}A.restore()};a.jqplot.OHLCRenderer.prototype.drawShadow=function(b,d,c){};a.jqplot.OHLCRenderer.checkOptions=function(d,c,b){if(!b.highlighter){b.highlighter={showMarker:false,tooltipAxes:"y",yvalues:4,formatString:'
    date:%s
    open:%s
    hi:%s
    low:%s
    close:%s
    '}}}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.pieRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pieRenderer.min.js new file mode 100644 index 000000000..a09f8f107 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pieRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(e){e.jqplot.PieRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.PieRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.PieRenderer.prototype.constructor=e.jqplot.PieRenderer;e.jqplot.PieRenderer.prototype.init=function(q,u){this.diameter=null;this.padding=20;this.sliceMargin=0;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this.dataLabelPositionFactor=0.52;this.dataLabelNudge=2;this.dataLabelCenterOn=true;this.startAngle=0;this.tickRenderer=e.jqplot.PieTickRenderer;this._drawData=true;this._type="pie";if(q.highlightMouseDown&&q.highlightMouseOver==null){q.highlightMouseOver=false}e.extend(true,this,q);if(this.sliceMargin<0){this.sliceMargin=0}this._diameter=null;this._radius=null;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var s=0;s570)?o[p]*0.8:o[p]+0.3*(255-o[p]);o[p]=parseInt(o[p],10)}this.highlightColors.push("rgb("+o[0]+","+o[1]+","+o[2]+")")}}this.highlightColorGenerator=new e.jqplot.ColorGenerator(this.highlightColors);u.postParseOptionsHooks.addOnce(m);u.postInitHooks.addOnce(g);u.eventListenerHooks.addOnce("jqplotMouseMove",b);u.eventListenerHooks.addOnce("jqplotMouseDown",a);u.eventListenerHooks.addOnce("jqplotMouseUp",l);u.eventListenerHooks.addOnce("jqplotClick",f);u.eventListenerHooks.addOnce("jqplotRightClick",n);u.postDrawHooks.addOnce(i)};e.jqplot.PieRenderer.prototype.setGridData=function(t){var p=[];var u=[];var o=this.startAngle/180*Math.PI;var s=0;this._drawData=false;for(var r=0;r0){p[r]+=p[r-1]}s+=this.data[r][1]}var q=Math.PI*2/p[p.length-1];for(var r=0;r0){p[r]+=p[r-1]}s+=t[r][1]}var q=Math.PI*2/p[p.length-1];for(var r=0;r0&&s>0.01&&s<6.282){w=parseFloat(p)/2/h(q)}return w}e.jqplot.PieRenderer.prototype.drawSlice=function(B,z,y,u,w){if(this._drawData){var p=this._radius;var A=this.fill;var x=this.lineWidth;var s=this.sliceMargin;if(this.fill==false){s+=this.lineWidth}B.save();B.translate(this._center[0],this._center[1]);var D=j(z,y,this.sliceMargin,this.fill,this.lineWidth);var o=D*Math.cos((z+y)/2);var C=D*Math.sin((z+y)/2);if((y-z)<=Math.PI){p-=D}else{p+=D}B.translate(o,C);if(w){for(var v=0,t=this.shadowDepth;v6.282+this.startAngle){y=6.282+this.startAngle;if(z>y){z=6.281+this.startAngle}}if(z>=y){return}B.beginPath();B.fillStyle=u;B.strokeStyle=u;B.lineWidth=x;B.arc(0,0,r,z,y,false);B.lineTo(0,0);B.closePath();if(A){B.fill()}else{B.stroke()}}};e.jqplot.PieRenderer.prototype.draw=function(B,z,E,o){var W;var H=(E!=undefined)?E:{};var t=0;var s=0;var N=1;var L=new e.jqplot.ColorGenerator(this.seriesColors);if(E.legendInfo&&E.legendInfo.placement=="insideGrid"){var J=E.legendInfo;switch(J.location){case"nw":t=J.width+J.xoffset;break;case"w":t=J.width+J.xoffset;break;case"sw":t=J.width+J.xoffset;break;case"ne":t=J.width+J.xoffset;N=-1;break;case"e":t=J.width+J.xoffset;N=-1;break;case"se":t=J.width+J.xoffset;N=-1;break;case"n":s=J.height+J.yoffset;break;case"s":s=J.height+J.yoffset;N=-1;break;default:break}}var K=(H.shadow!=undefined)?H.shadow:this.shadow;var A=(H.fill!=undefined)?H.fill:this.fill;var C=B.canvas.width;var I=B.canvas.height;var Q=C-t-2*this.padding;var X=I-s-2*this.padding;var M=Math.min(Q,X);var Y=M;this._sliceAngles=[];var v=this.sliceMargin;if(this.fill==false){v+=this.lineWidth}var q;var G=0;var R,aa,Z,ab;var D=this.startAngle/180*Math.PI;for(var W=0,V=z.length;WMath.PI){G=Math.max(q,G)}}if(this.diameter!=null&&this.diameter>0){this._diameter=this.diameter-2*G}else{this._diameter=Y-2*G}if(this._diameter<6){e.jqplot.log("Diameter of pie too small, not rendering.");return}var S=this._radius=this._diameter/2;this._center=[(C-N*t)/2+N*t+G*Math.cos(D),(I-N*s)/2+N*s+G*Math.sin(D)];if(this.shadow){for(var W=0,V=z.length;W=this.dataLabelThreshold){var F,U=(this._sliceAngles[W][0]+this._sliceAngles[W][1])/2,T;if(this.dataLabels=="label"){F=this.dataLabelFormatString||"%s";T=e.jqplot.sprintf(F,z[W][0])}else{if(this.dataLabels=="value"){F=this.dataLabelFormatString||"%d";T=e.jqplot.sprintf(F,this.data[W][1])}else{if(this.dataLabels=="percent"){F=this.dataLabelFormatString||"%d%%";T=e.jqplot.sprintf(F,z[W][2]*100)}else{if(this.dataLabels.constructor==Array){F=this.dataLabelFormatString||"%s";T=e.jqplot.sprintf(F,this.dataLabels[W])}}}}var p=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var P=this._center[0]+Math.cos(U)*p+this.canvas._offsets.left;var O=this._center[1]+Math.sin(U)*p+this.canvas._offsets.top;var u=e('
    '+T+"
    ").insertBefore(o.eventCanvas._elem);if(this.dataLabelCenterOn){P-=u.width()/2;O-=u.height()/2}else{P-=u.width()*Math.sin(U/2);O-=u.height()/2}P=Math.round(P);O=Math.round(O);u.css({left:P,top:O})}}};e.jqplot.PieAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PieAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PieAxisRenderer.prototype.constructor=e.jqplot.PieAxisRenderer;e.jqplot.PieAxisRenderer.prototype.init=function(o){this.tickRenderer=e.jqplot.PieTickRenderer;e.extend(true,this,o);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.PieLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.PieLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.PieLegendRenderer.prototype.constructor=e.jqplot.PieLegendRenderer;e.jqplot.PieLegendRenderer.prototype.init=function(o){this.numberRows=null;this.numberColumns=null;e.extend(true,this,o)};e.jqplot.PieLegendRenderer.prototype.draw=function(){var r=this;if(this.show){var B=this._series;this._elem=e(document.createElement("table"));this._elem.addClass("jqplot-table-legend");var E={position:"absolute"};if(this.background){E.background=this.background}if(this.border){E.border=this.border}if(this.fontSize){E.fontSize=this.fontSize}if(this.fontFamily){E.fontFamily=this.fontFamily}if(this.textColor){E.textColor=this.textColor}if(this.marginTop!=null){E.marginTop=this.marginTop}if(this.marginBottom!=null){E.marginBottom=this.marginBottom}if(this.marginLeft!=null){E.marginLeft=this.marginLeft}if(this.marginRight!=null){E.marginRight=this.marginRight}this._elem.css(E);var I=false,A=false,o,y;var C=B[0];var p=new e.jqplot.ColorGenerator(C.seriesColors);if(C.show){var J=C.data;if(this.numberRows){o=this.numberRows;if(!this.numberColumns){y=Math.ceil(J.length/o)}else{y=this.numberColumns}}else{if(this.numberColumns){y=this.numberColumns;o=Math.ceil(J.length/this.numberColumns)}else{o=J.length;y=1}}var H,G;var q,w,v;var x,z,F;var D=0;var u,t;for(H=0;H0){I=true}else{I=false}}else{if(H==o-1){I=false}else{I=true}}z=(I)?this.rowSpacing:"0";w=e(document.createElement("td"));w.addClass("jqplot-table-legend jqplot-table-legend-swatch");w.css({textAlign:"center",paddingTop:z});u=e(document.createElement("div"));u.addClass("jqplot-table-legend-swatch-outline");t=e(document.createElement("div"));t.addClass("jqplot-table-legend-swatch");t.css({backgroundColor:F,borderColor:F});w.append(u.append(t));v=e(document.createElement("td"));v.addClass("jqplot-table-legend jqplot-table-legend-label");v.css("paddingTop",z);if(this.escapeHtml){v.text(x)}else{v.html(x)}if(A){v.prependTo(q);w.prependTo(q)}else{w.appendTo(q);v.appendTo(q)}I=true}D++}}}}return this._elem};e.jqplot.PieRenderer.prototype.handleMove=function(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];r.target.trigger("jqplotDataMouseOver",o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.pieRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){r.target.trigger("jqplotDataHighlight",o);d(r,o[0],o[1])}}else{if(s==null){k(r)}}};function c(s,r,p){p=p||{};p.axesDefaults=p.axesDefaults||{};p.legend=p.legend||{};p.seriesDefaults=p.seriesDefaults||{};var o=false;if(p.seriesDefaults.renderer==e.jqplot.PieRenderer){o=true}else{if(p.series){for(var q=0;qB||s+C>m){z.remove()}z=null;f=null}}};c.jqplot.postSeriesInitHooks.push(c.jqplot.PointLabels.init);c.jqplot.postDrawSeriesHooks.push(c.jqplot.PointLabels.draw)})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js new file mode 100644 index 000000000..7b5db948f --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(e){e.jqplot.PyramidAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PyramidAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PyramidAxisRenderer.prototype.constructor=e.jqplot.PyramidAxisRenderer;e.jqplot.PyramidAxisRenderer.prototype.init=function(f){this.position=null;this.drawBaseline=true;this.baselineWidth=null;this.baselineColor=null;this.tickSpacingFactor=25;this._type="pyramid";this._splitAxis=false;this._splitLength=null;this.category=false;this._autoFormatString="";this._overrideFormatString=false;e.extend(true,this,f);this.renderer.options=f;this.resetDataBounds=this.renderer.resetDataBounds;this.resetDataBounds()};e.jqplot.PyramidAxisRenderer.prototype.resetDataBounds=function(){var h=this._dataBounds;h.min=null;h.max=null;var g;for(var m=0;mh.max)||h.max===null){h.max=g}}else{g=o[k][0];if((g!==null&&gh.max)||h.max===null){h.max=g}}}}};e.jqplot.PyramidAxisRenderer.prototype.draw=function(f,n){if(this.show){this.renderer.createTicks.call(this,n);var m=0;var g;if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=e(document.createElement("div"));this._elem.addClass("jqplot-axis jqplot-"+this.name);this._elem.css("position","absolute");if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var l=this._label.draw(f,n);l.appendTo(this._elem);l=null}var k=this._ticks;var j;for(var h=0;hr){I=this.numberTicks-1;for(H=2;H0;H--){v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[H-1].value+this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks[H].showGridline=false;this._ticks[H].showMark=false;this._ticks.splice(H,0,v)}v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[0].value-this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks.unshift(v);v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[this._ticks.length-1].value+this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks.push(v);this.tickInterval=this.tickInterval/2;this.numberTicks=this._ticks.length;this.min=this._ticks[0].value;this.max=this._ticks[this._ticks.length-1].value}}else{if(this.name.charAt(0)==="x"){E=this._plotDimensions.width;var w=Math.max(M.max,Math.abs(M.min));var u=Math.min(M.min,-w);B=u;G=w;y=G-B;if(this.tickOptions==null||!this.tickOptions.formatString){this._overrideFormatString=true}m=30;g=Math.max(E,m+1);j=(g-m)/300;O=e.jqplot.LinearTickGenerator(B,G,j);A=B+y*(this.padMin-1);F=G-y*(this.padMax-1);if(BF){A=B-y*(this.padMin-1);F=G+y*(this.padMax-1);O=e.jqplot.LinearTickGenerator(A,F,j)}this.min=O[0];this.max=O[1];this.numberTicks=O[2];this._autoFormatString=O[3];this.tickInterval=O[4]}else{E=this._plotDimensions.height;B=M.min;G=M.max;x=this._series[0];this._ticks=[];y=G-B;if(d[y]){y+=1;G+=1}this.max=G;this.min=B;r=Math.round(2+E/this.tickSpacingFactor);if(y+1<=r){this.numberTicks=y+1;this.tickInterval=1}else{for(var H=r;H>1;H--){if(y/(H-1)===Math.round(y/(H-1))){this.numberTicks=H;this.tickInterval=y/(H-1);break}}}}if(this._overrideFormatString&&this._autoFormatString!=""){this.tickOptions=this.tickOptions||{};this.tickOptions.formatString=this._autoFormatString}var f;for(H=0;Ho){o=j}}}if(this.name==="yMidAxis"){for(m=0;m0){f=-q._textRenderer.height*Math.cos(-q._textRenderer.angle)/2}else{f=-q.getHeight()+q._textRenderer.height*Math.cos(q._textRenderer.angle)/2}break;case"middle":f=-q.getHeight()/2;break;default:f=-q.getHeight()/2;break}}else{f=-q.getHeight()/2}var C=this.u2p(q.value)+f+"px";q._elem.css("top",C);q.pack()}}if(r){var y=this._label._elem.outerHeight(true);if(this.name!=="yMidAxis"){this._label._elem.css("top",o-k/2-y/2+"px")}if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{if(this.name!=="yMidAxis"){this._label._elem.css("right","0px")}}this._label.pack()}}}B=null}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidGridRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidGridRenderer.min.js new file mode 100644 index 000000000..25769919d --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidGridRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(a){a.jqplot.PyramidGridRenderer=function(){a.jqplot.CanvasGridRenderer.call(this)};a.jqplot.PyramidGridRenderer.prototype=new a.jqplot.CanvasGridRenderer();a.jqplot.PyramidGridRenderer.prototype.constructor=a.jqplot.PyramidGridRenderer;a.jqplot.CanvasGridRenderer.prototype.init=function(c){this._ctx;this.plotBands={show:false,color:"rgb(230, 219, 179)",axis:"y",start:null,interval:10};a.extend(true,this,c);var b={lineJoin:"miter",lineCap:"round",fill:false,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.shadowWidth,closePath:false,strokeStyle:this.shadowColor};this.renderer.shadowRenderer.init(b)};a.jqplot.PyramidGridRenderer.prototype.draw=function(){this._ctx=this._elem.get(0).getContext("2d");var D=this._ctx;var G=this._axes;var q=G.xaxis.u2p;var J=G.yMidAxis.u2p;var l=G.xaxis.max/1000;var u=q(0);var f=q(l);var r=["xaxis","yaxis","x2axis","y2axis","yMidAxis"];D.save();D.clearRect(0,0,this._plotDimensions.width,this._plotDimensions.height);D.fillStyle=this.backgroundColor||this.background;D.fillRect(this._left,this._top,this._width,this._height);if(this.plotBands.show){D.save();var c=this.plotBands;D.fillStyle=c.color;var d;var o,n,p,I;if(c.axis.charAt(0)==="x"){if(G.xaxis.show){d=G.xaxis}}else{if(c.axis.charAt(0)==="y"){if(G.yaxis.show){d=G.yaxis}else{if(G.y2axis.show){d=G.y2axis}else{if(G.yMidAxis.show){d=G.yMidAxis}}}}}if(d!==undefined){var g=c.start;if(g===null){g=d.min}for(var H=g;H0;H--){var O=r[H-1];var d=G[O];var M=d._ticks;var B=M.length;if(d.show){if(d.drawBaseline){var N={};if(d.baselineWidth!==null){N.lineWidth=d.baselineWidth}if(d.baselineColor!==null){N.strokeStyle=d.baselineColor}switch(O){case"xaxis":if(G.yMidAxis.show){z(this._left,this._bottom,u,this._bottom,N);z(f,this._bottom,this._right,this._bottom,N)}else{z(this._left,this._bottom,this._right,this._bottom,N)}break;case"yaxis":z(this._left,this._bottom,this._left,this._top,N);break;case"yMidAxis":z(u,this._bottom,u,this._top,N);z(f,this._bottom,f,this._top,N);break;case"x2axis":if(G.yMidAxis.show){z(this._left,this._top,u,this._top,N);z(f,this._top,this._right,this._top,N)}else{z(this._left,this._bottom,this._right,this._bottom,N)}break;case"y2axis":z(this._right,this._bottom,this._right,this._top,N);break}}for(var E=B;E>0;E--){var v=M[E-1];if(v.show){var k=Math.round(d.u2p(v.value))+0.5;switch(O){case"xaxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(k,this._top,k,this._bottom)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._bottom;K=this._bottom+A;break;case"inside":L=this._bottom-A;K=this._bottom;break;case"cross":L=this._bottom-A;K=this._bottom+A;break;default:L=this._bottom;K=this._bottom+A;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[k,L],[k,K]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}z(k,L,k,K)}break;case"yaxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._right,k,this._left,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._left-A;K=this._left;break;case"inside":L=this._left;K=this._left+A;break;case"cross":L=this._left-A;K=this._left+A;break;default:L=this._left-A;K=this._left;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;case"yMidAxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._left,k,u,k);z(f,k,this._right,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;L=u;K=u+A;if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor});L=f-A;K=f;if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;case"x2axis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(k,this._bottom,k,this._top)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._top-A;K=this._top;break;case"inside":L=this._top;K=this._top+A;break;case"cross":L=this._top-A;K=this._top+A;break;default:L=this._top-A;K=this._top;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[k,L],[k,K]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}z(k,L,k,K)}break;case"y2axis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._left,k,this._right,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._right;K=this._right+A;break;case"inside":L=this._right-A;K=this._right;break;case"cross":L=this._right-A;K=this._right+A;break;default:L=this._right;K=this._right+A;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;default:break}}}v=null}d=null;M=null}D.restore();function z(j,i,e,b,h){D.save();h=h||{};if(h.lineWidth==null||h.lineWidth!=0){a.extend(true,D,h);D.beginPath();D.moveTo(j,i);D.lineTo(e,b);D.stroke()}D.restore()}if(this.shadow){if(G.yMidAxis.show){var F=[[this._left,this._bottom],[u,this._bottom]];this.renderer.shadowRenderer.draw(D,F);var F=[[f,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(D,F);var F=[[u,this._bottom],[u,this._top]];this.renderer.shadowRenderer.draw(D,F)}else{var F=[[this._left,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(D,F)}}if(this.borderWidth!=0&&this.drawBorder){if(G.yMidAxis.show){z(this._left,this._top,u,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(f,this._top,this._right,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:G.y2axis.borderColor,lineWidth:G.y2axis.borderWidth});z(this._right,this._bottom,f,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(u,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth});z(u,this._bottom,u,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth});z(f,this._bottom,f,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth})}else{z(this._left,this._top,this._right,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:G.y2axis.borderColor,lineWidth:G.y2axis.borderWidth});z(this._right,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth})}}D.restore();D=null;G=null}})(jQuery); \ No newline at end of file diff --git a/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidRenderer.min.js b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidRenderer.min.js new file mode 100644 index 000000000..9266e2273 --- /dev/null +++ b/templates/admin/default/assets/js/jqplot/plugins/jqplot.pyramidRenderer.min.js @@ -0,0 +1,3 @@ +/* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com + jsDate | (c) 2010-2013 Chris Leonello + */(function(c){if(c.jqplot.PyramidAxisRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidAxisRenderer.js",dataType:"script",async:false})}if(c.jqplot.PyramidGridRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidGridRenderer.js",dataType:"script",async:false})}c.jqplot.PyramidRenderer=function(){c.jqplot.LineRenderer.call(this)};c.jqplot.PyramidRenderer.prototype=new c.jqplot.LineRenderer();c.jqplot.PyramidRenderer.prototype.constructor=c.jqplot.PyramidRenderer;c.jqplot.PyramidRenderer.prototype.init=function(j,o){j=j||{};this._type="pyramid";this.barPadding=10;this.barWidth=null;this.fill=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.highlightThreshold=2;this.synchronizeHighlight=false;this.offsetBars=false;if(j.highlightMouseDown&&j.highlightMouseOver==null){j.highlightMouseOver=false}this.side="right";c.extend(true,this,j);if(this.side==="left"){this._highlightThreshold=[[-this.highlightThreshold,0],[-this.highlightThreshold,0],[0,0],[0,0]]}else{this._highlightThreshold=[[0,0],[0,0],[this.highlightThreshold,0],[this.highlightThreshold,0]]}this.renderer.options=j;this._highlightedPoint=null;this._dataColors=[];this._barPoints=[];this.fillAxis="y";this._primaryAxis="_yaxis";this._xnudge=0;var n={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shapeRenderer.init(n);var m=j.shadowOffset;if(m==null){if(this.lineWidth>2.5){m=1.25*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{m=1.25*Math.atan((this.lineWidth/2.5))/0.785398163}}var h={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,angle:this.shadowAngle,offset:m,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shadowRenderer.init(h);o.postDrawHooks.addOnce(f);o.eventListenerHooks.addOnce("jqplotMouseMove",e);if(this.side==="left"){for(var k=0,g=this.data.length;k=0){s=I[E][0]-L;F=this.barWidth;D=[L,n-y-r,s,F]}else{s=L-I[E][0];F=this.barWidth;D=[I[E][0],n-y-r,s,F]}this._barPoints.push([[D[0],D[1]+F],[D[0],D[1]],[D[0]+s,D[1]],[D[0]+s,D[1]+F]]);if(p){this.renderer.shadowRenderer.draw(B,D)}var g=u.fillStyle||this.color;this._dataColors.push(g);this.renderer.shapeRenderer.draw(B,D,u)}else{if(E===0){D=[[L,j],[I[E][0],j],[I[E][0],I[E][1]-y-r]]}else{if(E=h.synchronizeHighlight&&h.synchronizeHighlight!==l){h=m.series[h.synchronizeHighlight];k={fillStyle:h.highlightColors[j],fillRect:false};h.renderer.shapeRenderer.draw(g._ctx,h._barPoints[j],k)}g=null}function d(j){var g=j.plugins.pyramidRenderer.highlightCanvas;g._ctx.clearRect(0,0,g._ctx.canvas.width,g._ctx.canvas.height);for(var h=0;h .btn { + width: 100%; + .form-control-focus(); +} + + +.dropdown-menu { + z-index: 2000; +} + +.bootstrap-select.show-menu-arrow.open > .btn { + z-index: 2051; +} + +.bootstrap-select.btn-group .btn .filter-option { + overflow: hidden; + position: absolute; + left: 12px; + right: 25px; + text-align: left; + color: @input-color; +} + +.bootstrap-select.btn-group .btn .caret { + position: absolute; + top: 50%; + right: 12px; + margin-top: -2px; + vertical-align: middle; +} + +.bootstrap-select.btn-group > .disabled, +.bootstrap-select.btn-group .dropdown-menu li.disabled > a { + cursor: not-allowed; +} + +.bootstrap-select.btn-group > .disabled:focus { + outline: none !important; +} + +.bootstrap-select.btn-group[class*="span"] .btn { + width: 100%; +} + +.bootstrap-select.btn-group .dropdown-menu { + min-width: 100%; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.bootstrap-select.btn-group .dropdown-menu.inner { + position: static; + border: 0; + padding: 0; + margin: 0; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.bootstrap-select.btn-group .dropdown-menu dt { + display: block; + padding: 3px 20px; + cursor: default; +} + +.bootstrap-select.btn-group .div-contain { + overflow: hidden; +} + +.bootstrap-select.btn-group .dropdown-menu li a{ + color: @input-color; + + &:hover{ + color: #FFF; + } +} + +.bootstrap-select.btn-group .dropdown-menu li { + position: relative; + + &:focus, a:focus{ + outline: none; + } +} + +.bootstrap-select.btn-group .dropdown-menu li > a.opt { + position: relative; + padding-left: 35px; +} + +.bootstrap-select.btn-group .dropdown-menu li > a { + cursor: pointer; +} + +.bootstrap-select.btn-group .dropdown-menu li > dt small { + font-weight: normal; +} + +.bootstrap-select.btn-group.show-tick .dropdown-menu li.selected a i.check-mark { + display: inline-block; + position: absolute; + right: 15px; + margin-top: 2.5px; +} + +.bootstrap-select.btn-group .dropdown-menu li a i.check-mark { + display: none; +} + +.bootstrap-select.btn-group.show-tick .dropdown-menu li a span.text { + margin-right: 34px; +} + +.bootstrap-select.btn-group .dropdown-menu li small { + padding-left: 0.5em; +} + +.bootstrap-select.btn-group .dropdown-menu li:not(.disabled) > a:hover small, +.bootstrap-select.btn-group .dropdown-menu li:not(.disabled) > a:focus small { + color: #64b1d8; + color: rgba(255,255,255,0.4); +} + +.bootstrap-select.btn-group .dropdown-menu li > dt small { + font-weight: normal; +} + +.bootstrap-select.show-menu-arrow .dropdown-toggle:before { + content: ''; + display: inline-block; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-bottom: 7px solid #CCC; + border-bottom-color: rgba(0, 0, 0, 0.2); + position: absolute; + bottom: -4px; + left: 9px; + display: none; +} + +.bootstrap-select.show-menu-arrow .dropdown-toggle:after { + content: ''; + display: inline-block; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid white; + position: absolute; + bottom: -4px; + left: 10px; + display: none; +} + +.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:before { + bottom: auto; + top: -3px; + border-top: 7px solid #ccc; + border-bottom: 0; + border-top-color: rgba(0, 0, 0, 0.2); +} + +.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:after { + bottom: auto; + top: -3px; + border-top: 6px solid #ffffff; + border-bottom: 0; +} + +.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:before { + right: 12px; + left: auto; +} +.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:after { + right: 13px; + left: auto; +} + +.bootstrap-select.show-menu-arrow.open > .dropdown-toggle:before, +.bootstrap-select.show-menu-arrow.open > .dropdown-toggle:after { + display: block; +} + +.mobile-device { + position: absolute; + top: 0; + left: 0; + display: block !important; + width: 100%; + height: 100% !important; + opacity: 0; +} + +.bootstrap-select.fit-width { + width: auto !important; +} + +.bootstrap-select.btn-group.fit-width .btn .filter-option { + position: static; +} + +.bootstrap-select.btn-group.fit-width .btn .caret { + position: static; + top: auto; + margin-top: -1px; +} + +.control-group.error .bootstrap-select .dropdown-toggle{ + border-color: #b94a48; +} + +.bootstrap-select-searchbox { + padding: 4px 8px; +} diff --git a/templates/admin/default/assets/less/thelia/forms.less b/templates/admin/default/assets/less/thelia/forms.less index 52c4b5b54..2291c15e9 100755 --- a/templates/admin/default/assets/less/thelia/forms.less +++ b/templates/admin/default/assets/less/thelia/forms.less @@ -167,6 +167,36 @@ form .info { } } +// Form validation states +// +// Used in forms.less to generate the form validation CSS for warnings, errors, +// and successes. + +.form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) { + // Color the label and help text + .help-block, + .control-label { + color: @text-color; + } + // Set the border and box shadow on specific inputs to match + .form-control, .bootstrap-select .btn { + border-color: @border-color; + .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work + &:focus { + border-color: darken(@border-color, 10%); + @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@border-color, 20%); + .box-shadow(@shadow); + } + } + // Set validation states also for addons + .input-group-addon { + color: @text-color; + border-color: @border-color; + background-color: @background-color; + } +} + + // -- Sign in -- .form-signin{ // .form-control { diff --git a/templates/admin/default/assets/less/thelia/grid.less b/templates/admin/default/assets/less/thelia/grid.less new file mode 100644 index 000000000..6ea63b46b --- /dev/null +++ b/templates/admin/default/assets/less/thelia/grid.less @@ -0,0 +1,11 @@ +@media (max-width: @screen-desktop) { + + .navbar-form{ + width: 100%; + + .form-group{ + width: 94%; + } + } + +} \ No newline at end of file diff --git a/templates/admin/default/assets/less/thelia/jqplot.less b/templates/admin/default/assets/less/thelia/jqplot.less new file mode 100644 index 000000000..ab8683cbc --- /dev/null +++ b/templates/admin/default/assets/less/thelia/jqplot.less @@ -0,0 +1,27 @@ +.jqplot-axis{ + color: @gray-light; + font-family: @font-family-sans-serif; + font-size: @font-size-small; +} + +.jqplot-yaxis{ + margin-right: 10px; +} +.jqplot-xaxis{ + margin-top: 10px; +} + +.jqplot-highlighter-tooltip{ + .tooltip-inner; +} + +.jqplot-title{ + text-transform: uppercase; + font-weight: bold; + font-size: 12px; + color: @gray; +} + +.jqplot-series-canvas{ + .opacity(0.7); +} \ No newline at end of file diff --git a/templates/admin/default/assets/less/thelia/navbar.less b/templates/admin/default/assets/less/thelia/navbar.less index 26f9cd569..a0080e775 100755 --- a/templates/admin/default/assets/less/thelia/navbar.less +++ b/templates/admin/default/assets/less/thelia/navbar.less @@ -30,4 +30,8 @@ .navbar-default .navbar-toggle .icon-bar{ background-color: @btn-primary-color; +} + +.navbar-form{ + padding: 0; } \ No newline at end of file diff --git a/templates/admin/default/assets/less/thelia/scaffolding.less b/templates/admin/default/assets/less/thelia/scaffolding.less index 1309638e4..01b6fbaf7 100755 --- a/templates/admin/default/assets/less/thelia/scaffolding.less +++ b/templates/admin/default/assets/less/thelia/scaffolding.less @@ -7,8 +7,9 @@ // ------------------------- body { - background: #FFF url("@{imgDir}/bg.jpg") top left no-repeat; - background-size: cover; + // background: #FFF url("@{imgDir}/bg.jpg") top left no-repeat; + // background-size: cover; + background-color: #eee; } diff --git a/templates/admin/default/assets/less/thelia/tables.less b/templates/admin/default/assets/less/thelia/tables.less index 8a4baa897..e542786ec 100755 --- a/templates/admin/default/assets/less/thelia/tables.less +++ b/templates/admin/default/assets/less/thelia/tables.less @@ -1,3 +1,22 @@ +// Baseline styles + +.table { + + // Cells + thead, + tbody, + tfoot { + > tr { + > th, + > td { + vertical-align: middle; + } + } + } + +} + + tfoot{ .pagination{ diff --git a/templates/admin/default/assets/less/thelia/thelia.less b/templates/admin/default/assets/less/thelia/thelia.less index ac525566f..822130a5c 100644 --- a/templates/admin/default/assets/less/thelia/thelia.less +++ b/templates/admin/default/assets/less/thelia/thelia.less @@ -2,14 +2,18 @@ @import "navbar.less"; @import "scaffolding.less"; @import "type.less"; +@import "grid.less"; @import "breadcrumbs.less"; @import "forms.less"; @import "datepicker.less"; @import "modals.less"; @import "tables.less"; @import "tablesorter.less"; +@import "wizard.less"; @import "bootstrap-editable.less"; @import "bootstrap-switch.less"; +@import "bootstrap-select.less"; +@import "jqplot.less"; // -- Base styling ------------------------------------------------------------ @@ -33,7 +37,7 @@ .topbar { - background: url("@{imgDir}/top.jpg") repeat-x; + background: url("@{imgDir}/top.jpg") repeat-x; font-weight: bold; .version-info { @@ -201,7 +205,7 @@ border-bottom: 2px solid #A5CED8; margin-bottom: 0.5em; } - + // The action bar on the right .actions { text-align: right; @@ -216,6 +220,10 @@ text-transform: none; } } + + .inner-actions { + margin-top: 0.5em; + } } // The overall form container @@ -249,6 +257,11 @@ } } +// -- Home -- +.dashboard hr{ + margin-bottom: 10px; +} + // -- Editable tweaks --------------------------------------------------------- .editable-click, a.editable-click, a.editable-click:hover { diff --git a/templates/admin/default/assets/less/thelia/wizard.less b/templates/admin/default/assets/less/thelia/wizard.less new file mode 100644 index 000000000..0d130a2d5 --- /dev/null +++ b/templates/admin/default/assets/less/thelia/wizard.less @@ -0,0 +1,129 @@ +.wizard { + background-color: #fff; + border: 1px solid #d4d4d4; + border-radius: 4px; + .box-shadow(0 1px 4px rgba(0, 0, 0, 0.065)); + *zoom: 1; + margin-bottom: 20px; + + &:before, + &:after { + display: table; + line-height: 0; + content: ""; + clear: both; + } + + ul { + padding: 0; + margin: 0; + list-style: none outside none; + } + + li { + position: relative; + float: left; + height: 46px; + padding: 0 10px 0 30px; + margin: 0; + font-size: 15px; + line-height: 46px; + color: #999999; + cursor: default; + background: #ededed; + + &.complete { + color: #468847; + background: #f3f4f5; + + &:hover{ + background: #e8e8e8; + + .chevron:before { + border-left: 14px solid #e8e8e8; + } + } + + a{ + color: inherit; + text-decoration: none; + font-weight: normal; + } + + .chevron:before { + border-left: 14px solid #f3f4f5; + } + + } + + &.active { + color: @link-color; + background: #fff; + + .chevron:before { + border-left: 14px solid #fff; + } + } + + .chevron { + position: absolute; + top: 0; + right: -14px; + display: block; + border: 24px solid transparent; + border-right: 0; + border-left: 14px solid #d4d4d4; + + &:before { + position: absolute; + top: -24px; + right: 1px; + display: block; + border: 24px solid transparent; + border-right: 0; + border-left: 14px solid #ededed; + content: ""; + } + + } + + .badge { + margin-right: 8px; + } + + &:nth-child(1) { + z-index: 10; + padding-left: 20px; + border-radius: 4px 0 0 4px; + } + &:nth-child(2) { + z-index: 9; + } + &:nth-child(3) { + z-index: 8; + } + &:nth-child(4) { + z-index: 7; + } + &:nth-child(5) { + z-index: 6; + } + &:nth-child(6) { + z-index: 5; + } + &:nth-child(7) { + z-index: 4; + } + &:nth-child(8) { + z-index: 3; + } + &:nth-child(9) { + z-index: 2; + } + &:nth-child(10) { + z-index: 1; + } + + } + +} \ No newline at end of file diff --git a/templates/admin/default/attribute-edit.html b/templates/admin/default/attribute-edit.html index 882edd60c..676a99baa 100644 --- a/templates/admin/default/attribute-edit.html +++ b/templates/admin/default/attribute-edit.html @@ -77,95 +77,97 @@
    {intl l="Enter here all possible attribute values."}
    + +
    + + + + -
    + {admin_sortable_header + current_order=$attributeav_order + order='id' + reverse_order='id_reverse' + request_parameter_name='attributeav_order' + path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} + label="{intl l='ID'}" + } +
    - - - + - + - + {module_include location='attributes_value_table_header'} - {module_include location='attributes_value_table_header'} + + + - - - + + {loop name="list" type="attribute_availability" attribute=$attribute_id backend_context="1" lang=$edit_language_id order=$attributeav_order} + + - - {loop name="list" type="attribute_availability" attribute=$attribute_id backend_context="1" lang=$edit_language_id order=$attributeav_order} - - + - + - + {module_include location='attributes_value_table_row'} - {module_include location='attributes_value_table_row'} + + + {/loop} - - - {/loop} - - {elseloop rel="list"} - - - - {/elseloop} - -
    - {admin_sortable_header - current_order=$attributeav_order - order='id' - reverse_order='id_reverse' - request_parameter_name='attributeav_order' - path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} - label="{intl l='ID'}" - } - + {admin_sortable_header + current_order=$attributeav_order + order='alpha' + reverse_order='alpha_reverse' + request_parameter_name='attributeav_order' + path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} + label="{intl l='Value'}" + } + - {admin_sortable_header - current_order=$attributeav_order - order='alpha' - reverse_order='alpha_reverse' - request_parameter_name='attributeav_order' - path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} - label="{intl l='Value'}" - } - + {admin_sortable_header + current_order=$attributeav_order + order='manual' + reverse_order='manual_reverse' + request_parameter_name='attributeav_order' + path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} + label="{intl l="Position"}" + } + - {admin_sortable_header - current_order=$attributeav_order - order='manual' - reverse_order='manual_reverse' - request_parameter_name='attributeav_order' - path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} - label="{intl l="Position"}" - } - {intl l="Actions"}
    {intl l="Actions"}
    {$ID}
    {$ID} + {* FIXME : integrate this in the encolsing form to provide standard form processing *} + + - {* FIXME : integrate this in the encolsing form to provide standard form processing *} - - + {admin_position_block + permission="admin.attributes.edit" + path={url path='/admin/configuration/attributes-av/update-position' attribute_id=$attribute_id} + url_parameter="attributeav_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" + } + - {admin_position_block - permission="admin.attributes.edit" - path={url path='/admin/configuration/attributes-av/update-position' attribute_id=$attribute_id} - url_parameter="attributeav_id" - in_place_edit_class="positionChange" - position="$POSITION" - id="$ID" - } - +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-av.delete"} + + + + {/loop} +
    +
    -
    - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-av.delete"} - - - - {/loop} -
    -
    -
    - {intl l="No value has been created yet. Click the + button to create one."} -
    -
    + {elseloop rel="list"} + + +
    + {intl l="No value has been created yet. Click the + button to create one."} +
    + + + {/elseloop} + + +
    {/form} diff --git a/templates/admin/default/attributes.html b/templates/admin/default/attributes.html index 57fd9c256..c207d02fa 100644 --- a/templates/admin/default/attributes.html +++ b/templates/admin/default/attributes.html @@ -21,117 +21,119 @@
    - - + + + {/elseloop} + +
    - {intl l='Thelia product attributes'} +
    + + - - - + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attributes.create"} + + + + {/loop} + + + + - + - + - {module_include location='attributes_table_header'} + {module_include location='attributes_table_header'} - - - + + + - - {loop name="list" type="attribute" backend_context="1" lang=$lang_id order=$order} - - + + {loop name="list" type="attribute" backend_context="1" lang=$lang_id order=$order} + + - + - + - {module_include location='attributes_table_row'} + {module_include location='attributes_table_row'} - - - {/loop} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.delete"} + + {/loop} + + + + {/loop} - {elseloop rel="list"} - - - - {/elseloop} - -
    + {intl l='Thelia product attributes'} - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attributes.create"} - - - - {/loop} -
    - {admin_sortable_header - current_order=$order - order='id' - reverse_order='id_reverse' - path='/admin/configuration/attributes' - label="{intl l='ID'}" - } -
    + {admin_sortable_header + current_order=$order + order='id' + reverse_order='id_reverse' + path='/admin/configuration/attributes' + label="{intl l='ID'}" + } + - {admin_sortable_header - current_order=$order - order='alpha' - reverse_order='alpha_reverse' - path='/admin/configuration/attributes' - label="{intl l='Title'}" - } - + {admin_sortable_header + current_order=$order + order='alpha' + reverse_order='alpha_reverse' + path='/admin/configuration/attributes' + label="{intl l='Title'}" + } + - {admin_sortable_header - current_order=$order - order='manual' - reverse_order='manual_reverse' - path='/admin/configuration/attributes' - label="{intl l="Position"}" - } - + {admin_sortable_header + current_order=$order + order='manual' + reverse_order='manual_reverse' + path='/admin/configuration/attributes' + label="{intl l="Position"}" + } + {intl l="Actions"}
    {intl l="Actions"}
    {$ID}
    {$ID} - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.change"} - {$TITLE} - {/loop} - {elseloop rel="can_change"} - {$TITLE} - {/elseloop} - + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.change"} + {$TITLE} + {/loop} + {elseloop rel="can_change"} + {$TITLE} + {/elseloop} + - {admin_position_block - permission="admin.attributes.edit" - path="/admin/configuration/attributes/update-position" - url_parameter="attribute_id" - in_place_edit_class="positionChange" - position="$POSITION" - id="$ID" - } - + {admin_position_block + permission="admin.attributes.edit" + path="/admin/configuration/attributes/update-position" + url_parameter="attribute_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" + } + - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.change"} - - {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.change"} + + {/loop} -
    - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.change"} - - {/loop} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.change"} + + {/loop} - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.attributes.delete"} - - {/loop} -
    -
    -
    - {intl l="No product attribute has been created yet. Click the + button to create one."} -
    -
    + {elseloop rel="list"} +
    +
    + {intl l="No product attribute has been created yet. Click the + button to create one."} +
    +
    +
    @@ -224,7 +226,7 @@ dialog_title = {intl l="Delete attribute"} dialog_message = {intl l="Do you really want to delete this attribute ? It will be removed from all product templates."} - form_action = {url path='/admin/configuration/attributes/remove_from-all-templates' attribute_id=$ID} + form_action = {url path='/admin/configuration/attributes/delete'} form_content = {$smarty.capture.delete_dialog nofilter} } diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 6fe06f8bc..990cafd56 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -1,517 +1,651 @@ {extends file="admin-layout.tpl"} -{block name="page-title"}{intl l='Catalog'}{/block} +{block name="page-title"}{intl l='Categories'}{/block} -{block name="check-permissions"}admin.catalog.view{/block} +{block name="check-permissions"}admin.categories.view{/block} {block name="main-content"} -
    -
    +
    - {include file="includes/catalog-breadcrumb.html"} +
    - {module_include location='catalog_top'} + {include file="includes/catalog-breadcrumb.html"} -
    -
    -
    - - -
    -
    -
    -
    - {* display parent category name, and get current cat ID *} - {loop name="category_title" type="category" visible="*" id=$current_category_id} - {intl l="Categories in %cat" cat=$TITLE} - {$cat_id = $ID} - {/loop} - {elseloop rel="category_title"} - {intl l="Top level categories"} - {/elseloop} + {module_include location='categories_top'} - {module_include location='category_list_caption'} +
    +
    +
    +
    + + + {module_include location='category_list_caption'} - {ifloop rel="category_list"} - - - + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} + + + + {/loop} + - + {ifloop rel="category_list"} + + + - + - {module_include location='category_list_header'} + - + {module_include location='category_list_header'} - + - - - + - - {loop name="category_list" type="category" visible="*" parent=$current_category_id order=$category_order backend_context="1" lang=$lang_id} - - + + + - + + {loop name="category_list" type="category" visible="*" parent=$category_id order=$category_order backend_context="1" lang=$lang_id} + + - + - {module_include location='category_list_row'} + - + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="category_list"} + + + + + + {/elseloop} +
    + {* display parent category name, and get current cat ID *} + {loop name="category_title" type="category" visible="*" id=$category_id} + {intl l="Categories in %cat" cat=$TITLE} + {$cat_id = $ID} + {/loop} + {elseloop rel="category_title"} + {intl l="Top level categories"} + {/elseloop} - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} - - - - {/loop} -
    - {admin_sortable_header - current_order=$category_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='ID'}" - } -  
    + {admin_sortable_header + current_order=$category_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='ID'}" + } + - {admin_sortable_header - current_order=$category_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Category title'}" - } -   + {admin_sortable_header + current_order=$category_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Category title'}" + } + - {admin_sortable_header - current_order=$category_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Online'}" - } - - {admin_sortable_header - current_order=$category_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Position'}" - } - + {admin_sortable_header + current_order=$category_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Online'}" + } + {intl l='Actions'}
    + {admin_sortable_header + current_order=$category_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Position'}" + } +
    {$ID}{intl l='Actions'}
    - {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} - {$TITLE} - {/loop} -
    {$ID} - - {$TITLE} - - + {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + {$TITLE} + {/loop} + + + {$TITLE} + + - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} -
    - -
    - {/loop} + {module_include location='category_list_row'} - {elseloop rel="can_change"} -
    - -
    - {/elseloop} -
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} +
    + +
    + {/loop} -
    - {admin_position_block - permission="admin.categories.edit" - path={url path='admin/category/update-position' category_id=$ID} - url_parameter="category_id" - in_place_edit_class="categoryPositionChange" - position=$POSITION - id=$ID + {elseloop rel="can_change"} +
    + +
    + {/elseloop} +
    + {admin_position_block + permission="admin.categories.edit" + path={url path='admin/categories/update-position' category_id=$ID} + url_parameter="category_id" + in_place_edit_class="categoryPositionChange" + position=$POSITION + id=$ID + } + +
    + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"} + + {/loop} +
    +
    +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} + {intl l="This category has no sub-categories. To create a new one, click the + button above."} + {/loop} + + {elseloop rel="can_create"} + {intl l="This category has no sub-categories."} + {/elseloop} +
    +
    +
    +
    +
    +
    + +{* -- PRODUCT MANAGEMENT ---------------------------------------------------- *} + +
    +
    +
    +
    + + + + {ifloop rel="product_list"} + + + - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} - - {/loop} + - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"} - - {/loop} - - - - {/loop} - - {/ifloop} + - - - - - {/elseloop} -
    + {* display parent category name *} + {loop name="category_title" type="category" visible="*" id=$category_id} + {intl l="Products in %cat" cat=$TITLE} + {/loop} + + {elseloop rel="category_title"} + {intl l="Top level Products"} + {/elseloop} + + {module_include location='product_list_caption'} + + + + +
    + {admin_sortable_header + current_order=$product_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='ID'}" } - - -
    - +
      + {admin_sortable_header + current_order=$product_order + order='ref' + reverse_order='ref_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Reference'}" + } +
    + {admin_sortable_header + current_order=$product_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Product title'}" + } - {elseloop rel="category_list"} -
    -
    - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} - {intl l="This category has no sub-categories. To create a new one, click the + button above."} - {/loop} + {module_include location='product_list_header'} - {elseloop rel="can_create"} - {intl l="This category has no sub-categories."} - {/elseloop} -
    -
    -
    -
    -
    +
    + {admin_sortable_header + current_order=$product_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Online'}" + } +
    - - {elseloop rel="category_title"} - {intl l="Top level Products"} - {/elseloop} + + + - {module_include location='product_list_caption'} + + {loop name="product_list" type="product" visible="*" category_default=$category_id order=$product_order} + + - - - - + - - - + - + {module_include location='product_list_row'} - - - - - - - - - - {loop name="product_list" type="product" category=$current_category_id order="manual"} - - - - - - - - {module_include location='product_list_row'} - - + - + - - - {/loop} - - {/ifloop} + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.delete"} + + {/loop} + + + + {/loop} + + {/ifloop} - {elseloop rel="product_list"} - - - - - - {/elseloop} -
    - {* display parent category name *} - {loop name="category_title" type="category" visible="*" id=$current_category_id} - {intl l="Products in %cat" cat=$TITLE} - {/loop} +
    + {admin_sortable_header + current_order=$product_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Position'}" + } +  
    {$ID} + {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + + {$TITLE} + + {/loop} - {ifloop rel="product_list"} -
    - {admin_sortable_header - current_order=$product_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='ID'}" - } + {$REF} {$TITLE} - {admin_sortable_header - current_order=$product_order - order='ref' - reverse_order='ref_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Reference'}" - } - - {admin_sortable_header - current_order=$product_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Product title'}" - } - - {module_include location='product_list_header'} - - - {admin_sortable_header - current_order=$product_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Online'}" - } - - {admin_sortable_header - current_order=$product_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Position'}" - } -  
    {$ID} - {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} - - {$TITLE} - - {/loop} - - {$REF}{$TITLE} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"} -
    - +
    +
    {/loop} {elseloop rel="can_change"} -
    - -
    +
    + +
    {/elseloop} -
    - {admin_position_block - permission="admin.product.edit" - path={url path='admin/product' category_id=$ID} - url_parameter="product_id" - in_place_edit_class="productPositionChange" - position=$POSITION - id=$ID - } - + {admin_position_block + permission="admin.product.edit" + path={url path='/admin/products/update-position' product_id=$ID} + url_parameter="product_id" + in_place_edit_class="productPositionChange" + position=$POSITION + id=$ID + } + -
    - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"} - - {/loop} +
    +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"} + + {/loop} - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.delete"} - - {/loop} -
    -
    {intl l="This category doesn't have any products. To add a new product, click the + button above."}
    -
    -
    -
    + {elseloop rel="product_list"} + + +
    {intl l="This category doesn't contains any products. To add a new product, click the + button above."}
    + + + {/elseloop} + +
    +
    +
    +
    - {module_include location='catalog_bottom'} - + {module_include location='categories_bottom'} + + + + {module_include location='catalog_bottom'} - {* Adding a new Category *} - {form name="thelia.admin.category.creation"} +{* -- Adding a new category ------------------------------------------------- *} - {* Capture the dialog body, to pass it to the generic dialog *} - {capture "category_creation_dialog"} +{form name="thelia.admin.category.creation"} - {form_hidden_fields form=$form} + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "category_creation_dialog"} - {form_field form=$form field='success_url'} - {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} - - {/form_field} + {form_hidden_fields form=$form} - {form_field form=$form field='parent'} - - {/form_field} + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} - {form_field form=$form field='title'} -
    - + {form_field form=$form field='parent'} + + {/form_field} - {loop type="lang" name="default-lang" default_only="1"} + {form_field form=$form field='title'} +
    + + {loop type="lang" name="default-lang" default_only="1"} +
    + + $TITLE +
    -
    - - $TITLE -
    +
    {intl l='Enter here the category name in the default language (%title)' title="$TITLE"}
    -
    {intl l='Enter here the category name in the default language (%title)' title="$TITLE"}
    + {* Switch edition to the current locale *} + - {* Switch edition to the current locale *} - + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} - {form_field form=$form field='locale'} - - {/form_field} - {/loop} -
    - {/form_field} + {form_field form=$form field='visible'} +
    +
    + +
    +
    + {/form_field} - {module_include location='category_create_form'} - - {/capture} - - {include - file = "includes/generic-create-dialog.html" - - dialog_id = "add_category_dialog" - dialog_title = {intl l="Create a new category"} - dialog_body = {$smarty.capture.category_creation_dialog nofilter} - - dialog_ok_label = {intl l="Create this category"} - dialog_cancel_label = {intl l="Cancel"} - - form_action = {url path='/admin/categories/create'} - form_enctype = {form_enctype form=$form} - form_error_message = $form_error_message - } - {/form} - - {* Delete category confirmation dialog *} - - {capture "category_delete_dialog"} - - - - {module_include location='category_delete_form'} + {module_include location='category_create_form'} {/capture} {include - file = "includes/generic-confirm-dialog.html" + file = "includes/generic-create-dialog.html" - dialog_id = "delete_category_dialog" - dialog_title = {intl l="Delete a category"} - dialog_message = {intl l="Do you really want to delete this category, and all its contents ?"} + dialog_id = "category_creation_dialog" + dialog_title = {intl l="Create a new category"} + dialog_body = {$smarty.capture.category_creation_dialog nofilter} - form_action = {url path='/admin/categories/delete'} - form_content = {$smarty.capture.category_delete_dialog nofilter} + dialog_ok_label = {intl l="Create this category"} + + form_action = {url path='/admin/categories/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message } +{/form} + +{* -- Adding a new product -------------------------------------------------- *} + +{form name="thelia.admin.product.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "product_creation_dialog"} + + {form_hidden_fields form=$form} + + {* Be sure to get the category_id, even if the form could not be validated *} + + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='default_category'} + + {/form_field} + + {form_field form=$form field='ref'} +
    + + +
    + +
    + +
    {intl l='Enter here the product reference'}
    +
    + {/form_field} + + {form_field form=$form field='title'} +
    + + {loop type="lang" name="default-lang" default_only="1"} +
    + + $TITLE +
    + +
    {intl l='Enter here the product name in the default language (%title)' title="$TITLE"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {form_field form=$form field='visible'} +
    +
    + +
    +
    + {/form_field} + + {module_include location='product_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "product_creation_dialog" + dialog_title = {intl l="Create a new product"} + dialog_body = {$smarty.capture.product_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this product"} + + form_action = {url path='/admin/products/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* -- Delete category confirmation dialog ----------------------------------- *} + +{capture "category_delete_dialog"} + + + {module_include location='category_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "category_delete_dialog" + dialog_title = {intl l="Delete category"} + dialog_message = {intl l="Do you really want to delete this category and all its content ?"} + + form_action = {url path='/admin/categories/delete'} + form_content = {$smarty.capture.category_delete_dialog nofilter} +} + +{* -- Delete product confirmation dialog ------------------------------------ *} + +{capture "product_delete_dialog"} + + + + {module_include location='product_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "product_delete_dialog" + dialog_title = {intl l="Delete product"} + dialog_message = {intl l="Do you really want to delete this product ?"} + + form_action = {url path='/admin/products/delete'} + form_content = {$smarty.capture.product_delete_dialog nofilter} +} {/block} {block name="javascript-initialization"} - {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} - - {/javascripts} + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} - {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} - - {/javascripts} + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} - + {/block} \ No newline at end of file diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index e01849475..b974a4564 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -8,226 +8,375 @@
    - {include file="includes/catalog-breadcrumb.html"} + {include file="includes/catalog-breadcrumb.html" editing_category="true"}
    - {loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edit_language_id"} + {loop name="category_edit" type="category" visible="*" id="{$category_id}" backend_context="1" lang="$edit_language_id"}
    - {intl l='Edit category'} + {intl l='Edit category %title' title=$TITLE}
    - - - + + {if $HAS_PREVIOUS != 0} + + {else} + + {/if} + + + + {if $HAS_NEXT != 0} + + {else} + + {/if}
    -
    +
    +
    -
    - +
    -
    +
    -
    -
    -
    +
    - {include file="includes/inner-form-toolbar.html" close_url="{url path='admin/catalog/category/edit' category_id=$current_category_id}"} + {form name="thelia.admin.category.modification"} + -
    -
    -
    - + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/categories' category_id=$PARENT}"} -
    - -
    -
    + {* Be sure to get the category ID, even if the form could not be validated *} + -
    - + -
    - -
    -
    + {form_hidden_fields form=$form} -
    - + {form_field form=$form field='success_url'} + + {/form_field} -
    - + {form_field form=$form field='locale'} + + {/form_field} -
    -
    + {if $form_error}
    {$form_error_message}
    {/if} -
    - + {include file="includes/standard-description-form-fields.html"} -
    - -
    -
    + {form_field form=$form field='url'} +
    + -
    - + +
    + {/form_field} -
    - -
    {intl l="The rewritten URL to the category page. Click \"Use Default\" button to use the default URL. Use only digits, letters, - and _ characters."}
    -
    -
    +
    +
    + {form_field form=$form field='parent'} +
    -
    -
    + -
    -
    -
    -   -
    -

    {intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}

    -
    -
    -
    -
    + +
    + {/form_field} +
    + +
    + {form_field form=$form field='visible'} +
    + +
    + +
    +
    + {/form_field} +
    +
    -
    -
    - - -
    - -
    -
    -
    - -
    -
    - - -
    - -
    -
    -
    -
    - -
    - - -
    - +   +
    +

    {intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    -
    +
    -
    -
    -
    + + {/form} +
    +
    -
    -

    Images

    -
    +
    +
    +
    +
    -
    - - {/loop} + + + + {ifloop rel="folders"} +
    + +
    +
    + +
    + {intl l='Select a folder to get its content'} +
    + +
    +
    +
    + + + + +
    + + {intl l='Select a content and click (+) to add it to this category'} +
    + +
    +
    + {intl l="No available content in this folder"} +
    +
    +
    + +
    + {/ifloop} + + {elseloop rel="folders"} +
    {intl l="No folders found"}
    + {/elseloop} + + +
    + +
    + + + + + + + + {module_include location='category_contents_table_header'} + + + + + + + {loop name="assigned_contents" type="associated_content" category="$category_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='category_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop} + +
    {intl l='ID'}{intl l='Content title'}{intl l="Actions"}
    {$ID} + {$TITLE} + +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.category.content.delete"} + + + + {/loop} +
    +
    +
    + {intl l="This category contains no contents"} +
    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + {/loop}
    + + +{* Delete related content confirmation dialog *} + +{capture "delete_content_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_content_dialog" + dialog_title = {intl l="Remove related content"} + dialog_message = {intl l="Do you really want to remove this related content ?"} + + form_action = {url path='/admin/categories/related-content/delete'} + form_content = {$smarty.capture.delete_content_dialog nofilter} +} {/block} {block name="javascript-initialization"} + + + + {/block} \ No newline at end of file diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html index 0bf0e9bed..50e9296ac 100644 --- a/templates/admin/default/configuration.html +++ b/templates/admin/default/configuration.html @@ -17,151 +17,156 @@
    diff --git a/templates/admin/default/content-edit.html b/templates/admin/default/content-edit.html new file mode 100644 index 000000000..a7b55dfb8 --- /dev/null +++ b/templates/admin/default/content-edit.html @@ -0,0 +1,344 @@ +{extends file="admin-layout.tpl"} + +{block name="check-permissions"}admin.content.view{/block} + +{block name="page-title"}{intl l='Edit content'}{/block} + +{block name="main-content"} +
    +
    + + {* include file="includes/folder-breadcrumb.html" editing_category="true" *} + +
    + {loop name="content_edit" type="content" visible="*" id="{$content_id}" backend_context="1" lang="$edit_language_id"} +
    +
    +
    + {intl l='Edit content %title' title=$TITLE} +
    + +
    + + {if $HAS_PREVIOUS != 0} + + {else} + + {/if} + + + + {if $HAS_NEXT != 0} + + {else} + + {/if} +
    +
    + +
    +
    + + + +
    + +
    + +
    + + {form name="thelia.admin.content.modification"} +
    + + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' parent=0}"} + + {* Be sure to get the folder ID, even if the form could not be validated *} + + + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {include file="includes/standard-description-form-fields.html"} + + {form_field form=$form field='url'} +
    + + + +
    + {/form_field} + +
    +
    + {form_field form=$form field='default_folder'} +
    + + + + +
    + {/form_field} +
    + +
    + {form_field form=$form field='visible'} +
    + +
    + +
    +
    + {/form_field} +
    +
    + +
    +
    +
    +   +
    +

    {intl l='Colder created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    +
    +
    +
    +
    + +
    + {/form} +
    +
    + +
    +
    +
    + +
    + + + + + + + + + {module_include location='folder_contents_table_header'} + + + + + + + {*loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='folder_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop*} + +
    {intl l='ID'}{intl l='Attribute title'}{intl l="Actions"}
    {$ID} + {$TITLE} + +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.folder.content.delete"} + + + + {/loop} +
    +
    +
    + {intl l="This folder contains no contents"} +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + {/loop} +
    +
    +
    + + +{* Delete related content confirmation dialog *} + + {capture "delete_content_dialog"} + + + + + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_content_dialog" + dialog_title = {intl l="Remove related content"} + dialog_message = {intl l="Do you really want to remove this related content ?"} + +form_action = {url path='/admin/folders/related-content/delete'} +form_content = {$smarty.capture.delete_content_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + +{/block} \ No newline at end of file diff --git a/templates/admin/default/countries.html b/templates/admin/default/countries.html new file mode 100644 index 000000000..fe1b614a1 --- /dev/null +++ b/templates/admin/default/countries.html @@ -0,0 +1,220 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Countries'}{/block} + +{block name="check-permissions"}admin.configuration.countries.view{/block} + +{block name="main-content"} +
    + +
    + + + + {module_include location='countries_top'} + +
    +
    + +
    + +
    +
    + + + + + + + + + + + + {module_include location='countries_table_header'} + + + + + + + {loop name="countries" type="country" backend_context="1" lang=$lang_id order=$order} + + + + + + + + + {module_include location='countries_table_row'} + + + + {/loop} + {elseloop rel="countries"} + + + + {/elseloop} + +
    + {intl l='Countries'} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.countries.create"} + + + + {/loop} +
    IDNameDefaultShopN° ISOISO Code{intl l='Actions'}
    {$ID}{$TITLE} +
    + +
    +
    +
    + +
    +
    {$ISOCODE}{$ISOALPHA3} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.countries.change"} + + + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.countries.delete"} + + + + {/loop} +
    +
    +
    + {intl l="No country has been created yet. Click the + button to create one."} +
    +
    +
    +
    + +
    + +
    + +
    + + {module_include location='countries_bottom'} + +
    +
    + + {* Adding a new Country *} + + {form name="thelia.admin.country.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "country_creation_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='title'} +
    + + +
    + {/form_field} + + {form_field form=$form field='area'} +
    + + +
    + {/form_field} + + {form_field form=$form field='isocode'} +
    + + +
    + {/form_field} + + {form_field form=$form field='isoalpha2'} +
    + + +
    + {/form_field} + + {form_field form=$form field='isoalpha3'} +
    + + +
    + {/form_field} + + {module_include location='country_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "add_country_dialog" + dialog_title = {intl l="Create a new country"} + dialog_body = {$smarty.capture.country_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this country"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path='/admin/configuration/countries/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } + {/form} + + + {* Delete confirmation dialog *} + + {capture "delete_dialog"} + + + {module_include location='country_delete_form'} + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete country"} + dialog_message = {intl l="Do you really want to delete this country ?"} + + form_action = {url path='/admin/configuration/countries/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} + } + +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + + + {/javascripts} + +{/block} \ No newline at end of file diff --git a/templates/admin/default/country-edit.html b/templates/admin/default/country-edit.html new file mode 100644 index 000000000..fe1a0f240 --- /dev/null +++ b/templates/admin/default/country-edit.html @@ -0,0 +1,147 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit a country'}{/block} + +{block name="check-permissions"}admin.configuration.countries.edit{/block} + +{block name="main-content"} +
    + +
    + + {loop name="country_edit" type="country" id="$country_id" backend_context="1" lang="$edit_language_id"} + + + +
    +
    +
    + +
    + {intl l="Edit country $TITLE"} +
    + +
    +
    + + {form name="thelia.admin.country.modification"} +
    + +
    +
    + {* Be sure to get the country ID, even if the form could not be validated *} + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='area'} +
    + + +
    + {/form_field} + + {form_field form=$form field='isocode'} +
    + + +
    + {/form_field} + + {form_field form=$form field='isoalpha2'} +
    + + +
    + {/form_field} + + {form_field form=$form field='isoalpha3'} +
    + + +
    + {/form_field} +
    + +
    + {intl l="Translations"} +
    + + {loop type="lang" name="lang"} +
    +
    +
    +

    + {intl l=$TITLE} {$TITLE} +

    +
    +
    + {form_field form=$form field='title'} +
    + + +
    + {/form_field} + {form_field form=$form field='short-description'} +
    + + +
    + {/form_field} + {form_field form=$form field='description'} +
    + + +
    + {/form_field} +
    +
    +
    + {/loop} + +
    + +
    +
    +
    + {/form} + +
    +
    + +
    +
    + +
    + + {/loop} + + {elseloop rel="country_edit"} +
    +
    +
    + {intl l="Sorry, country ID=$country_id was not found."} +
    +
    +
    + {/elseloop} + +
    +
    +{/block} \ No newline at end of file diff --git a/templates/admin/default/coupon-create.html b/templates/admin/default/coupon-create.html index e8fcb73f5..f8a0411e1 100755 --- a/templates/admin/default/coupon-create.html +++ b/templates/admin/default/coupon-create.html @@ -7,18 +7,19 @@ {form name="thelia.admin.coupon.creation"} {include file='coupon/form.html' formAction={url path={$formAction}} noRules=true} {/form} - {include file='includes/confirmation-modal.html'} @@ -33,9 +34,20 @@ {/javascripts} + {javascripts file='assets/js/json2.js'} + + {/javascripts} + + {javascripts file='assets/js/coupon.js'} + + {/javascripts} + + {**} + {**} + {/block} diff --git a/templates/admin/default/coupon-list.html b/templates/admin/default/coupon-list.html index e4a1d5e36..3abc9268d 100755 --- a/templates/admin/default/coupon-list.html +++ b/templates/admin/default/coupon-list.html @@ -7,141 +7,97 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - List of enabled coupons -
    CodeTitleExpiration dateUsage leftActions
    XMAS13Coupon for XMAS -30 €18/10/201349 - Edit - Disable -
    XMAS13Coupon for XMAS -30 €05/09/201320 - Edit - Disable -
    XMAS13Coupon for XMAS -30 €03/12/20139 - Edit - Disable -
    XMAS13Coupon for XMAS -30 €25/01/20134 - Edit - Disable -
    +
    + + + + + + + + + + + + + {loop type="coupon" name="list_coupon" is_enabled="1" backend_context="true"} + + + + + + + + {/loop} + +
    + {intl l='Enabled coupons'} +
    {block name="coupon-label-code"}{intl l='Code'}{/block}{block name="coupon-label-title"}{intl l='Title'}{/block}{block name="coupon-label-expiration-date"}{intl l='Expiration date'}{/block}{block name="coupon-label-usage-left"}{intl l='Usage left'}{/block}{block name="coupon-label-action"}{/block}
    {block name="coupon-code"}{$CODE}{/block}{block name="coupon-title"}{$TITLE}{/block}{block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block}{block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + {block name="coupon-action"} + + {intl l='Edit'} + + {/block} +
    +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - List of disabled coupons -
    CodeTitleExpiration dateUsage leftActions
    XMAS13Coupon for XMAS -30 €18/10/201349 - Edit - Enabled -
    XMAS13Coupon for XMAS -20 €05/09/201349 - Edit - Enabled -
    XMAS13Coupon for XMAS -50 €03/12/201349 - Edit - Enabled -
    XMAS13Coupon for XMAS -5 €25/01/201349 - Edit - Enabled -
    +
    + + + + + + + + + + + + + {loop type="coupon" name="list_coupon" is_enabled="0" backend_context="true"} + + + + + + + + {/loop} + +
    + {intl l='Disabled coupons'} +
    {block name="coupon-label-code"}{intl l='Code'}{/block}{block name="coupon-label-title"}{intl l='Title'}{/block}{block name="coupon-label-expiration-date"}{intl l='Expiration date'}{/block}{block name="coupon-label-usage-left"}{intl l='Usage left'}{/block}{block name="coupon-label-action"}{/block}
    {block name="coupon-code"}{$CODE}{/block}{block name="coupon-title"}{$TITLE}{/block}{block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block}{block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + {block name="coupon-action"} + + {intl l='Edit'} + + {/block} +
    +
    -{include file='includes/confirmation-modal.html' id="disable" message="{intl l='Do you really want to disable this element ?'}"} -{include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"} - {/block} diff --git a/templates/admin/default/coupon-read.html b/templates/admin/default/coupon-read.html index d0a86ac72..8f14dd44f 100755 --- a/templates/admin/default/coupon-read.html +++ b/templates/admin/default/coupon-read.html @@ -4,112 +4,148 @@ {block name="main-content"}
    - + {loop type="coupon" name="read_coupon" id={$couponId} backend_context="true"} - {loop type="coupon" name="read_coupon" id={$couponId} backend_context="true"} - - -
    -
    - -
    - - {if !$IS_ENABLED}{intl l='This coupon is disabled, you can enable to the bottom of this form.'}{/if} -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    {intl l='Title'}{$TITLE}
    {intl l='Expiration date'}{$EXPIRATION_DATE}
    {intl l='Usage left'} - {if $USAGE_LEFT} - - {$USAGE_LEFT} - - {else} - - 0 - - {/if} -
    {$SHORT_DESCRIPTION}
    {$DESCRIPTION}
    - {if $IS_CUMULATIVE} - - {intl l="May be cumulative"} - - {else} - - {intl l="Can't be cumulative"} - - {/if} -
    - {if $IS_REMOVING_POSTAGE} - - {intl l="Will remove postage"} - - {else} - - {intl l="Won't remove postage"} - - {/if} -
    {intl l='Amount'}{$AMOUNT}
    {intl l='Application field'} -
      - {foreach from=$APPLICATION_CONDITIONS item=rule name=rulesForeach} - {if !$smarty.foreach.rulesForeach.first} -
    • {intl l='And'}
    • - {/if} -
    • {$rule nofilter}
    • - {/foreach} -
    -
    {intl l='Actions'} - {intl l='Edit'} - {intl l='Enabled'} -
    - {/loop} + -
    + +
    +
    + + {if !$IS_ENABLED} +
    + + {intl l='This coupon is disabled, you can enable to the bottom of this form.'} +
    + {/if} + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l='Title'}{$TITLE}
    + {if $IS_ENABLED} + + {intl l="Is enabled"} + + {else} + + {intl l="Is disabled"} + + {/if} +
    + {$TOOLTIP} +
    {intl l='Amount'}{$AMOUNT}
    {intl l='Expiration date'}{$EXPIRATION_DATE} ({$DAY_LEFT_BEFORE_EXPIRATION} {intl l="days left"})
    {intl l='Usage left'} + {if $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} +
    + {if $IS_CUMULATIVE} + + {intl l="May be cumulative"} + + {else} + + {intl l="Can't be cumulative"} + + {/if} +
    + {if $IS_REMOVING_POSTAGE} + + {intl l="Will remove postage"} + + {else} + + {intl l="Won't remove postage"} + + {/if} +
    + {if $IS_AVAILABLE_ON_SPECIAL_OFFERS} + + {intl l="Will be available on special offers"} + + {else} + + {intl l="Won't be available on special offers"} + + {/if} +
    {intl l='Application field'} +
      + {foreach from=$APPLICATION_CONDITIONS item=rule name=rulesForeach} + {if !$smarty.foreach.rulesForeach.first} +
    • {intl l='And'}
    • + {/if} +
    • {$rule nofilter}
    • + {/foreach} +
    +
    {$SHORT_DESCRIPTION}
    {$DESCRIPTION}
    + + {intl l='Edit'} + +
    +
    +
    +
    + {/loop}
    {include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"} diff --git a/templates/admin/default/coupon-update.html b/templates/admin/default/coupon-update.html index 16771539a..0902dae4c 100755 --- a/templates/admin/default/coupon-update.html +++ b/templates/admin/default/coupon-update.html @@ -7,19 +7,20 @@ {form name="thelia.admin.coupon.creation"} {include file='coupon/form.html' formAction={url path={$formAction}} form=$form noRules=false} {/form} - {/block} @@ -71,8 +72,6 @@ // Save Rules AJAX couponManager.saveRuleAjax = function() { $('#constraint-add-operators-values').html('
    '); - console.log('about to save'); - console.log(couponManager.rulesToSave); var $url = '{$urlAjaxUpdateRules}'; $.ajax({ type: "POST", @@ -88,6 +87,11 @@ }).done(function(data) { $('#constraint-list').html(data); $('#constraint-add-operators-values').html(''); + // Set the rule selector + $("#category-rule option").filter(function() { + return $(this).val() == 'thelia.constraint.rule.available_for_everyone'; + }).prop('selected', true); + couponManager.onClickUpdateRule(); couponManager.onClickDeleteRule(); }); @@ -109,13 +113,22 @@ } }).done(function(data) { $('#constraint-add-operators-values').html(data); - + couponManager.ruleToSave.serviceId = ruleId; + if (ruleId == -1) { + // Placeholder can't be saved + $('#constraint-save-btn').hide(); + } else { + $('#constraint-save-btn').show(); + } return callBack(); }); }; // Rules which will be saved couponManager.rulesToSave = couponManager.initRules(); + + $('#constraint-save-btn').hide(); + }); {/block} diff --git a/templates/admin/default/coupon/form.html b/templates/admin/default/coupon/form.html index 5d30d201d..a4ec8b14a 100644 --- a/templates/admin/default/coupon/form.html +++ b/templates/admin/default/coupon/form.html @@ -11,152 +11,155 @@ {/form_field} {form_field form=$form field='success_url'} - + {/form_field}
    -
    - - {form_field form=$form field='code'} + {form_field form=$form field='code'} +
    + {if $error}{$message}{/if} - {/form_field} -
    +
    + {/form_field} -
    - - {form_field form=$form field='title'} + {form_field form=$form field='title'} +
    + {if $error}{$message}{/if} - {/form_field} -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - {form_field form=$form field='expirationDate'} - - {if $error}{$message}{/if} - {/form_field} -
    -
    + {/form_field} -
    - - - {form_field form=$form field='maxUsage'} + {form_field form=$form field='isEnabled'} +
    + +
    + {/form_field} + + {form_field form=$form field='isAvailableOnSpecialOffers'} +
    + +
    + {/form_field} + + {form_field form=$form field='isCumulative'} +
    + +
    + {/form_field} + + {form_field form=$form field='isRemovingPostage'} +
    + +
    + {/form_field} + + {form_field form=$form field='expirationDate'} +
    + +
    + + {if $error}{$message}{/if} + +
    +
    + {/form_field} + + {form_field form=$form field='maxUsage'} +
    + + + {if $error}{$message}{/if} - {/form_field} -
    +
    + {/form_field}
    -
    - - {form_field form=$form field='effect'} + {form_field form=$form field='effect'} +
    + {if $error}{$message}{/if} - {/form_field} - {$availableCoupons.0.toolTip} -
    + {$availableCoupons.0.toolTip} +
    + {/form_field}
    -
    - - {form_field form=$form field='amount'} + {form_field form=$form field='amount'} +
    + {$value} + {if $error}{$message}{/if} - {/form_field} -
    -
    - +
    + {/form_field} + {*
    *} + {**} {*form_field form=$form field='category'*} - + {**} {*if $error}{$message}{/if}*} {*/form_field*} -
    + {*
    *}
    -
    - - {form_field form=$form field='shortDescription'} - + {form_field form=$form field='shortDescription'} +
    + + {if $error}{$message}{/if} - {/form_field} -
    +
    + {/form_field}
    -
    - - {form_field form=$form field='description'} + {form_field form=$form field='description'} +
    + {if $error}{$message}{/if} - {/form_field} -
    +
    + {/form_field} - +
    @@ -186,22 +189,23 @@
    - + {intl l='Save this rule'}
    - {foreach from=$input.availableOperators key=k item=availableOperator} + {foreach from=$input.availableOperators key=k item=availableOperator name=availableOperators} {/foreach} @@ -11,7 +11,7 @@
    {if $input.type == 'select'} @@ -72,12 +72,16 @@ + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/features.html b/templates/admin/default/features.html new file mode 100644 index 000000000..683374aa8 --- /dev/null +++ b/templates/admin/default/features.html @@ -0,0 +1,328 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Thelia Product Features'}{/block} + +{block name="check-permissions"}admin.configuration.features.view{/block} + +{block name="main-content"} +
    + +
    + + + + {module_include location='features_top'} + +
    +
    +
    +
    +
    + + + + + + + + + + + {module_include location='features_table_header'} + + + + + + + {loop name="list" type="feature" backend_context="1" lang=$lang_id order=$order} + + + + + + + + {module_include location='features_table_row'} + + + + {/loop} + + {elseloop rel="list"} + + + + {/elseloop} + +
    + {intl l='Thelia product features'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.features.create"} + + + + {/loop} +
    + {admin_sortable_header + current_order=$order + order='id' + reverse_order='id_reverse' + path='/admin/configuration/features' + label="{intl l='ID'}" + } + + {admin_sortable_header + current_order=$order + order='alpha' + reverse_order='alpha_reverse' + path='/admin/configuration/features' + label="{intl l='Title'}" + } + + {admin_sortable_header + current_order=$order + order='manual' + reverse_order='manual_reverse' + path='/admin/configuration/features' + label="{intl l="Position"}" + } + {intl l="Actions"}
    {$ID} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.change"} + {$TITLE} + {/loop} + {elseloop rel="can_change"} + {$TITLE} + {/elseloop} + + {admin_position_block + permission="admin.features.edit" + path="/admin/configuration/features/update-position" + url_parameter="feature_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" + } + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.change"} + + {/loop} + +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.change"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.delete"} + + {/loop} +
    +
    +
    + {intl l="No product feature has been created yet. Click the + button to create one."} +
    +
    +
    +
    +
    +
    +
    + + {module_include location='features_bottom'} + +
    +
    + +{* Adding a new feature *} + +{form name="thelia.admin.feature.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "creation_dialog"} + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created feature ID, see controller *} + + {/form_field} + + {form_field form=$form field='title'} +
    + + + {loop type="lang" name="default-lang" default_only="1"} +
    + + {intl l=$TITLE} +
    + +
    {intl l="Enter here the feature name in the default language ($TITLE)"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {form_field form=$form field='add_to_all'} +
    +
    + + {intl l='Check this box if you want to add this features to all product templates'} +
    +
    + {/form_field} + + {module_include location='feature_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "creation_dialog" + dialog_title = {intl l="Create a new feature"} + dialog_body = {$smarty.capture.creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this feature"} + + form_action = {url path='/admin/configuration/features/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* Delete confirmation dialog *} + +{capture "delete_dialog"} + + + {module_include location='feature_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete feature"} + dialog_message = {intl l="Do you really want to delete this feature ? It will be removed from all product templates."} + + form_action = {url path='/admin/configuration/features/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} +} + + +{* Add to all dialog *} + +{capture "add_to_all_dialog"} + + + {module_include location='feature_add_to_all_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "add_to_all_dialog" + dialog_title = {intl l="Add to all product templates"} + dialog_message = {intl l="Do you really want to add this feature to all product templates ?"} + + form_action = {url path='/admin/configuration/features/add-to-all-templates'} + form_content = {$smarty.capture.add_to_all_dialog nofilter} +} + +{* Remove from all dialog *} + +{capture "remove_from_all_dialog"} + + + {module_include location='feature_add_to_all_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "remove_from_all_dialog" + dialog_title = {intl l="Remove from all product templates"} + dialog_message = {intl l="Do you really want to remove this feature from all product templates ? You'll loose all product related data for this feature."} + + form_action = {url path='/admin/configuration/features/remove-from-all-templates'} + form_content = {$smarty.capture.remove_from_all_dialog nofilter} +} + +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/folder-edit.html b/templates/admin/default/folder-edit.html new file mode 100644 index 000000000..1821f3bcc --- /dev/null +++ b/templates/admin/default/folder-edit.html @@ -0,0 +1,344 @@ +{extends file="admin-layout.tpl"} + +{block name="check-permissions"}admin.folder.view{/block} + +{block name="page-title"}{intl l='Edit folder'}{/block} + +{block name="main-content"} +
    +
    + + {* include file="includes/folder-breadcrumb.html" editing_category="true" *} + +
    + {loop name="folder_edit" type="folder" visible="*" id="{$folder_id}" backend_context="1" lang="$edit_language_id"} +
    +
    +
    + {intl l='Edit folder %title' title=$TITLE} +
    + +
    + + {if $HAS_PREVIOUS != 0} + + {else} + + {/if} + + + + {if $HAS_NEXT != 0} + + {else} + + {/if} +
    +
    + +
    +
    + + + +
    + +
    + +
    + + {form name="thelia.admin.folder.modification"} +
    + + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' folder_id=$folder_id}"} + + {* Be sure to get the folder ID, even if the form could not be validated *} + + + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {include file="includes/standard-description-form-fields.html"} + + {form_field form=$form field='url'} +
    + + + +
    + {/form_field} + +
    +
    + {form_field form=$form field='parent'} +
    + + + + +
    + {/form_field} +
    + +
    + {form_field form=$form field='visible'} +
    + +
    + +
    +
    + {/form_field} +
    +
    + +
    +
    +
    +   +
    +

    {intl l='Colder created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    +
    +
    +
    +
    + +
    + {/form} +
    +
    + +
    +
    +
    + +
    + + + + + + + + + {module_include location='folder_contents_table_header'} + + + + + + + {*loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='folder_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop*} + +
    {intl l='ID'}{intl l='Attribute title'}{intl l="Actions"}
    {$ID} + {$TITLE} + +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.folder.content.delete"} + + + + {/loop} +
    +
    +
    + {intl l="This folder contains no contents"} +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + {/loop} +
    +
    +
    + + +{* Delete related content confirmation dialog *} + +{capture "delete_content_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_content_dialog" + dialog_title = {intl l="Remove related content"} + dialog_message = {intl l="Do you really want to remove this related content ?"} + + form_action = {url path='/admin/folders/related-content/delete'} + form_content = {$smarty.capture.delete_content_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + +{/block} \ No newline at end of file diff --git a/templates/admin/default/folders.html b/templates/admin/default/folders.html new file mode 100644 index 000000000..fca34ba21 --- /dev/null +++ b/templates/admin/default/folders.html @@ -0,0 +1,632 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Folders'}{/block} + +{block name="check-permissions"}admin.folders.view{/block} + +{block name="main-content"} +
    + +
    + + {* include file="includes/folder-breadcrumb.html" *} + + {module_include location='folders_top'} + +
    +
    +
    +
    + + + {module_include location='folder_list_caption'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.folders.create"} + + + + {/loop} + + + {ifloop rel="folder_list"} + + + + + + + + + {module_include location='folder_list_header'} + + + + + + + + + + + {loop name="folder_list" type="folder" visible="*" parent=$parent order=$folder_order backend_context="1" lang=$lang_id} + + + + + + + + {module_include location='folder_list_row'} + + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="folder_list"} + + + + + + {/elseloop} +
    + {* display parent folder name, and get current folder ID *} + {loop name="folder_title" type="folder" visible="*" id=$parent} + {intl l="Folders in %fold" fold=$TITLE} + {$fold_id = $ID} + {/loop} + {elseloop rel="folder_title"} + {intl l="Top level folders"} + {/elseloop} + +
    + + {$TITLE} + +
    + {admin_sortable_header + current_order=$folder_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/folders' parent=$parent} + request_parameter_name='folder_order' + label="{intl l='ID'}" + } +   + {admin_sortable_header + current_order=$folder_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/folders' parent=$parent} + request_parameter_name='folder_order' + label="{intl l='Folder title'}" + } + + {admin_sortable_header + current_order=$folder_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/folders' parent=$parent} + request_parameter_name='folder_order' + label="{intl l='Online'}" + } + + {admin_sortable_header + current_order=$folder_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/folders' parent=$parent} + request_parameter_name='folder_order' + label="{intl l='Position'}" + } + {intl l='Actions'}
    {$ID} + {loop type="image" name="folder_image" source="folder" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + {$TITLE} + {/loop} + + + {$TITLE} + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"} +
    + +
    + {/loop} + + {elseloop rel="can_change"} +
    + +
    + {/elseloop} +
    + {admin_position_block + permission="admin.folders.edit" + path={url path='admin/folders/update-position' folder_id=$ID} + url_parameter="folder_id" + in_place_edit_class="folderPositionChange" + position=$POSITION + id=$ID + } + +
    + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.folders.delete"} + + {/loop} +
    +
    +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.folders.create"} + {intl l="This folder has no sub-folders. To create a new one, click the + button above."} + {/loop} + + {elseloop rel="can_create"} + {intl l="This folder has no sub-folders."} + {/elseloop} +
    +
    +
    +
    +
    +
    + +{* -- CONTENT MANAGEMENT ---------------------------------------------------- *} + +
    +
    +
    +
    + + + + {ifloop rel="content_list"} + + + + + + + + + + + + + + {loop name="content_list" type="content" visible="*" folder_default=$parent order=$content_order} + + + + + + {module_include location='content_list_row'} + + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="content_list"} + + + + + + {/elseloop} +
    + {* display parent folder name *} + {loop name="folder_title" type="folder" visible="*" id=$parent} + {intl l="Contents in %fold" fold=$TITLE} + {/loop} + + {elseloop rel="folder_title"} + {intl l="Top level Contents"} + {/elseloop} + + {module_include location='content_list_caption'} + + + + +
    + {admin_sortable_header + current_order=$content_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/folders' parent=$parent target='contents'} + label="{intl l='ID'}" + } + +   + {admin_sortable_header + current_order=$content_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/folders' parent=$parent target='contents'} + label="{intl l='Content title'}" + } + + {module_include location='content_list_header'} + + + {admin_sortable_header + current_order=$content_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/folders' parent=$parent target='contents'} + label="{intl l='Online'}" + } + + {admin_sortable_header + current_order=$content_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/folders' parent=$parent target='contents'} + label="{intl l='Position'}" + } +  
    {$ID} + {loop type="image" name="folder_image" source="content" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + + {$TITLE} + + {/loop} + + {$TITLE} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.contents.edit"} +
    + +
    + {/loop} + + {elseloop rel="can_change"} +
    + +
    + {/elseloop} +
    + {admin_position_block + permission="admin.content.edit" + path={url path='/admin/contents/update-position' content_id=$ID} + url_parameter="content_id" + in_place_edit_class="contentPositionChange" + position=$POSITION + id=$ID + } + +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.content.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.content.delete"} + + {/loop} +
    +
    {intl l="This folder doesn't contains any contents. To add a new content, click the + button above."}
    +
    + +
    +
    +
    + + {module_include location='folders_bottom'} + +
    + +
    + + +{* -- Adding a new folder ------------------------------------------------- *} + +{form name="thelia.admin.folder.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "folder_creation_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='parent'} + + {/form_field} + + {form_field form=$form field='title'} +
    + + {loop type="lang" name="default-lang" default_only="1"} +
    + + $TITLE +
    + +
    {intl l='Enter here the folder name in the default language (%title)' title="$TITLE"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {form_field form=$form field='visible'} +
    +
    + +
    +
    + {/form_field} + + {module_include location='folder_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "folder_creation_dialog" + dialog_title = {intl l="Create a new folder"} + dialog_body = {$smarty.capture.folder_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this folder"} + + form_action = {url path='/admin/folders/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* -- Adding a new content -------------------------------------------------- *} + +{form name="thelia.admin.content.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "content_creation_dialog"} + + {form_hidden_fields form=$form} + + {* Be sure to get the folder_id, even if the form could not be validated *} + + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='default_folder'} + + {/form_field} + + {form_field form=$form field='title'} +
    + + {loop type="lang" name="default-lang" default_only="1"} +
    + + $TITLE +
    + +
    {intl l='Enter here the content name in the default language (%title)' title="$TITLE"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {form_field form=$form field='visible'} +
    +
    + +
    +
    + {/form_field} + + {module_include location='content_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "content_creation_dialog" + dialog_title = {intl l="Create a new content"} + dialog_body = {$smarty.capture.content_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this content"} + + form_action = {url path='/admin/content/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* -- Delete folder confirmation dialog ----------------------------------- *} + +{capture "folder_delete_dialog"} + + + {module_include location='folder_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "folder_delete_dialog" + dialog_title = {intl l="Delete folder"} + dialog_message = {intl l="Do you really want to delete this folder and all its content ?"} + + form_action = {url path='/admin/folders/delete'} + form_content = {$smarty.capture.folder_delete_dialog nofilter} +} + +{* -- Delete content confirmation dialog ------------------------------------ *} + +{capture "content_delete_dialog"} + + + + {module_include location='content_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "content_delete_dialog" + dialog_title = {intl l="Delete content"} + dialog_message = {intl l="Do you really want to delete this content ?"} + + form_action = {url path='/admin/contents/delete'} + form_content = {$smarty.capture.content_delete_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/general_error.html b/templates/admin/default/general_error.html index 2c40f4038..eae6614c9 100755 --- a/templates/admin/default/general_error.html +++ b/templates/admin/default/general_error.html @@ -10,11 +10,13 @@
    -

    {intl l="Oops! An Error Occurred"}

    +
    +

    {intl l="Oops! An Error Occurred"}

    - {block name="error-message"}
    {$error_message}
    {/block} - -

    {intl l="Go to administration home"}

    + {block name="error-message"}

    {$error_message}

    {/block} + + {intl l="Go to administration home"} +
    diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index e2d8e785f..3371a1d9f 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -8,11 +8,391 @@ {module_include location='home_top'} -
    - This is the administration home page. Put some interesting statistics here, and display useful information :) +
    + +
    + {intl l='Dashboard'} +
    + + + +
    +
    + +
    +
    + + + + + +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    + + +
    +
    +
    +
    {intl l="Shop Informations"}
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="Customers"}1
    {intl l="Categories"}8
    {intl l="Products"}43
    {intl l="Online products"}43
    {intl l="Offline products"}0
    {intl l="Orders"}1
    {intl l="Pending orders"}1
    {intl l="In process orderst"}0
    {intl l="Shipped orders"}0
    {intl l="Canceled orders"}0
    +
    +
    +
    + +
    +
    +
    {intl l="Sales statistics"}
    + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="Overall sales"}2500.00 €
    {intl l="Sales excluding shipping"}2000.00 €
    {intl l="Yesterday sales"}1700.00 €
    {intl l="Waiting orders"}4
    {intl l="In process orders"}52
    {intl l="Canceled orders"}3
    {intl l="Average cart"}25.00 €
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="Overall sales"}2500.00 €
    {intl l="Sales excluding shipping"}2000.00 €
    {intl l="Previous month sales"}1700.00 €
    {intl l="Waiting orders"}4
    {intl l="In process orders"}52
    {intl l="Canceled orders"}3
    {intl l="Average cart"}25.00 €
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="Overall sales"}2500.00 €
    {intl l="Sales excluding shipping"}2000.00 €
    {intl l="Previous year sales"}1700.00 €
    {intl l="Waiting orders"}4
    {intl l="In process orders"}52
    {intl l="Canceled orders"}3
    {intl l="Average cart"}25.00 €
    +
    +
    +
    +
    +
    + +
    +
    +
    {intl l="Thelia informations"}
    +
    + + + + + + + + + + + + + + + +
    {intl l="Current version"}V2.0.0-beta
    {intl l="Latest version available"}V1.5.4.2
    {intl l="News"}{intl l="Click here"}
    +
    +
    +
    +
    {module_include location='home_bottom'}
    +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/jqplot/jquery.jqplot.min.js'} + + + {javascripts file='assets/js/jqplot/plugins/jqplot.highlighter.min.js'} + + {/javascripts} + {javascripts file='assets/js/jqplot/plugins/jqplot.barRenderer.min.js'} + + {/javascripts} + {javascripts file='assets/js/jqplot/plugins/jqplot.pieRenderer.min.js'} + + {/javascripts} + + + {/javascripts} {/block} \ No newline at end of file diff --git a/templates/admin/default/includes/catalog-breadcrumb.html b/templates/admin/default/includes/catalog-breadcrumb.html index b9312f0dd..1233d17a3 100644 --- a/templates/admin/default/includes/catalog-breadcrumb.html +++ b/templates/admin/default/includes/catalog-breadcrumb.html @@ -2,25 +2,27 @@ \ No newline at end of file diff --git a/templates/admin/default/includes/coupon_breadcrumb.html b/templates/admin/default/includes/coupon_breadcrumb.html deleted file mode 100755 index 878d9605d..000000000 --- a/templates/admin/default/includes/coupon_breadcrumb.html +++ /dev/null @@ -1,5 +0,0 @@ -{* Breadcrumb for coupon browsing and editing *} - -
  • Home
  • -
  • Coupon
  • -
  • Browse
  • \ No newline at end of file diff --git a/templates/admin/default/includes/folder-breadcrumb.html b/templates/admin/default/includes/folder-breadcrumb.html new file mode 100644 index 000000000..4319ba5ff --- /dev/null +++ b/templates/admin/default/includes/folder-breadcrumb.html @@ -0,0 +1,26 @@ +{* Breadcrumb for folders browsing and editing *} + + \ No newline at end of file diff --git a/templates/admin/default/includes/inner-form-toolbar.html b/templates/admin/default/includes/inner-form-toolbar.html index c142cbdd7..39da9fce7 100755 --- a/templates/admin/default/includes/inner-form-toolbar.html +++ b/templates/admin/default/includes/inner-form-toolbar.html @@ -21,8 +21,10 @@
    + {if $hide_submit_buttons != true} + {/if} {if ! empty($close_url)} {intl l='Close'} {/if} diff --git a/templates/admin/default/includes/standard-description-form-fields.html b/templates/admin/default/includes/standard-description-form-fields.html index 58fa319c1..17c340b27 100644 --- a/templates/admin/default/includes/standard-description-form-fields.html +++ b/templates/admin/default/includes/standard-description-form-fields.html @@ -25,7 +25,7 @@ {intl l="The détailed description."} - +
    {/form_field} diff --git a/templates/admin/default/includes/thelia_news_feed.html b/templates/admin/default/includes/thelia_news_feed.html deleted file mode 100755 index 09b3af020..000000000 --- a/templates/admin/default/includes/thelia_news_feed.html +++ /dev/null @@ -1,11 +0,0 @@ -{* this temlate is loaded via Ajax in the login page, to prevent login page slowdown *} - -{loop type="feed" name="thelia_feeds" url="http://thelia.net/Flux-rss.html?id_rubrique=8" limit="3"} -
    -

    {$DATE}

    -

    {$TITLE|strip_tags nofilter}

    - {* we use unescape:"htmlall" to unescape var before truncate, to prevent a cut in the middel of an HTML entity, eg &ea... *} -

    {$DESCRIPTION|strip_tags|unescape:"htmlall"|truncate:250:"...":true nofilter}

    -

    {intl l='Lire la suite »'}

    -
    -{/loop} diff --git a/templates/admin/default/login.html b/templates/admin/default/login.html index 07e238c88..c30eae514 100755 --- a/templates/admin/default/login.html +++ b/templates/admin/default/login.html @@ -6,52 +6,74 @@ {block name="page-title"}{intl l='Welcome'}{/block} {block name="main-content"} -
    +
    +
    + +
    +
    +
    + +

    {intl l='Thelia Back Office'}

    -
    +
    + {module_include location='index_top'} + + {form name="thelia.admin.login"} +
    - {module_include location='index_top'} + {if $form_error}
    {$form_error_message}
    {/if} -
    -

    {intl l='Thelia Back Office'}

    +
    + {intl l='Login'} + + {form_hidden_fields form=$form} - {form name="thelia.admin.login"} - + {form_field form=$form field='success_url'} + {* on success, redirect to /admin *} + {/form_field} + + {form_field form=$form field='username'} +
    + +
    + + +
    +
    + {/form_field} + {form_field form=$form field='password'} +
    + +
    + + +
    +
    + {/form_field} - {if $form_error}
    {$form_error_message}
    {/if} + {form_field form=$form field='remember_me'} +
    + +
    + {/form_field} - {form_hidden_fields form=$form} + +
    + + {/form} - {form_field form=$form field='success_url'} - {* on success, redirect to /admin *} - {/form_field} + {module_include location='index_middle'} +
    - {form_field form=$form field='username'} - - - - {/form_field} - - {form_field form=$form field='password'} - - - - {/form_field} - - {form_field form=$form field='remember_me'} - - {/form_field} - - - - {/form} -
    - - {module_include location='index_middle'} - -
    -
    -
    {intl l="Loading Thelia lastest news..."}
    +
    +
    +
    +
    {intl l="Loading Thelia lastest news..."}
    +
    +
    +
    @@ -59,12 +81,13 @@ {module_include location='index_bottom'}
    +
    {/block} {block name="javascript-initialization"} {/block} \ No newline at end of file diff --git a/templates/admin/default/message-edit.html b/templates/admin/default/message-edit.html index db6118c05..51e97d61d 100644 --- a/templates/admin/default/message-edit.html +++ b/templates/admin/default/message-edit.html @@ -43,7 +43,7 @@ {/form_field} {form_field form=$form field='id'} - + {/form_field} {form_field form=$form field='locale'} @@ -55,7 +55,7 @@ {form_field form=$form field='name'}
    - +
    {/form_field} @@ -71,14 +71,14 @@ {form_field form=$form field='title'}
    - +
    {/form_field} {form_field form=$form field='subject'}
    - +
    {/form_field} @@ -88,7 +88,7 @@ {intl l="{$label}"} : {intl l="The mailing template in HTML format."} - +
    {/form_field} @@ -98,7 +98,7 @@ {intl l="{$label}"} : {intl l="The mailing template in text-only format."} - +
    {/form_field} diff --git a/templates/admin/default/messages.html b/templates/admin/default/messages.html index afa7764af..cf2a0d9e1 100644 --- a/templates/admin/default/messages.html +++ b/templates/admin/default/messages.html @@ -21,76 +21,78 @@
    - - + + + {/elseloop} + +
    - {intl l='Thelia mailing templates'} - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.messages.create"} - - - - {/loop} +
    + + - - - - + + + + + - {module_include location='messages_table_header'} + {module_include location='messages_table_header'} - - - + + + - - {loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"} - + + {loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"} + - + - + {/if} + - {module_include location='messages_table_row'} + {module_include location='messages_table_row'} - - - {/loop} - {elseloop rel="mailing-templates"} - - - - {/elseloop} - -
    + {intl l='Thelia mailing templates'} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.messages.create"} + + + + {/loop} -
    {intl l="Purpose"}{intl l="Name"}
    {intl l="Purpose"}{intl l="Name"} 
     
    {$TITLE}{$TITLE} - {if ! $SECURED} - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} - {$NAME} - {/loop} - {elseloop rel="can_change"} + + {if ! $SECURED} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} + {$NAME} + {/loop} + {elseloop rel="can_change"} + {$NAME} + {/elseloop} + {else} {$NAME} - {/elseloop} - {else} - {$NAME} - {/if} - - {if ! $SECURED} -
    - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} - - {/loop} +
    + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} + + {/loop} - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.messages.delete"} - - {/loop} -
    - {else} - - {/if} -
    -
    - {intl l="No mailing template has been created yet. Click the + button to create one."} -
    -
    + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.messages.delete"} + + {/loop} +
    + {else} + + {/if} + + + {/loop} + {elseloop rel="mailing-templates"} +
    +
    + {intl l="No mailing template has been created yet. Click the + button to create one."} +
    +
    +
    diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html new file mode 100644 index 000000000..8c86c349a --- /dev/null +++ b/templates/admin/default/modules.html @@ -0,0 +1,276 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Modules'}{/block} + +{block name="check-permissions"}admin.modules.view{/block} + +{block name="main-content"} +
    + +
    + +
    + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.modules.install"} + + {intl l="Install a new module"} + + {/loop} +
    + + {module_include location='modules_top'} + +
    +
    +
    +
    + + + + + + + + + {module_include location='modules_table_header'} + + + + + + + + + + + + {module_include location='modules_table_row'} + + + + + + + + + {module_include location='modules_table_row'} + + + + + + + + + {module_include location='modules_table_row'} + + + + +
    + {intl l='Transport modules'} +
    {intl l="Name"}{intl l="Description"}{intl l="Enable/Disable"}{intl l="Actions"}
    TinymceEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid! Eius, pariatur accusantium odit quidem laboriosam. +
    + +
    +
    +
    + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
    +
    So colissimoEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid +
    + +
    +
    +
    + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
    +
    Title metaEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid +
    + +
    +
    +
    + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
    +
    +
    +
    + +
    +
    + + + + + + + + + {module_include location='modules_table_header'} + + + + + + + + + + + + {module_include location='modules_table_row'} + + + + + + + + + {module_include location='modules_table_row'} + + + + + + + + + {module_include location='modules_table_row'} + + + + +
    + {intl l='Delivery modules'} +
    {intl l="Name"}{intl l="Description"}{intl l="Enable/Disable"}{intl l="Actions"}
    TinymceEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid! Eius, pariatur accusantium odit quidem laboriosam. +
    + +
    +
    +
    + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
    +
    So colissimoEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid +
    + +
    +
    +
    + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
    +
    Title metaEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid +
    + +
    +
    +
    + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
    +
    +
    +
    +
    +
    + + {module_include location='modules_bottom'} + +
    +
    + +{* Delete module confirmation dialog *} + +{capture "delete_module_dialog"} + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_module_dialog" + dialog_title = {intl l="Delete a module"} + dialog_message = {intl l="Do you really want to delete this module ?"} + + form_action = {url path='/admin/modules/delete'} + form_content = {$smarty.capture.delete_module_dialog nofilter} +} + +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} +{/block} \ No newline at end of file diff --git a/templates/admin/default/product-edit.html b/templates/admin/default/product-edit.html new file mode 100644 index 000000000..d80d9ca0a --- /dev/null +++ b/templates/admin/default/product-edit.html @@ -0,0 +1,599 @@ +{extends file="admin-layout.tpl"} + +{block name="check-permissions"}admin.catalog.view{/block} + +{block name="page-title"}{intl l='Edit product'}{/block} + +{block name="main-content"} +
    +
    + + {include file="includes/catalog-breadcrumb.html" editing_category="false" editing_product="true"} + +
    + {loop name="product_edit" type="product" visible="*" id=$product_id backend_context="1" lang=$edit_language_id} +
    +
    +
    + {intl l='Edit product %title' title=$TITLE} +
    + +
    + + {if $HAS_PREVIOUS != 0} + + {else} + + {/if} + + + + {if $HAS_NEXT != 0} + + {else} + + {/if} +
    +
    + +
    +
    + + + +
    + +
    + +
    + + {form name="thelia.admin.product.modification"} +
    + + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/products' product_id=$product_id}"} + + {* Be sure to get the product ID, even if the form could not be validated *} + + + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + +
    + + +
    {$REF}
    +
    + + {include file="includes/standard-description-form-fields.html"} + + {form_field form=$form field='url'} +
    + + + +
    + {/form_field} + +
    +
    + + {form_field form=$form field='default_category'} +
    + + + + + {intl l='You can attach this product to more categories in the details tab.'} +
    + {/form_field} + +
    + +
    + {form_field form=$form field='visible'} +
    + +
    + +
    +
    + {/form_field} +
    +
    + +
    +
    +
    +   +
    +

    {intl l='Product created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    +
    +
    +
    +
    + +
    + {/form} +
    +
    + +
    +
    + + {include + file="includes/inner-form-toolbar.html" + hide_submit_buttons=true + close_url="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + + {* -- Begin related content management -- *} + +
    +
    + +
    + + + + + + + + + {module_include location='product_contents_table_header'} + + + + + + + {loop name="assigned_contents" type="associated_content" product="$product_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='product_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop} + +
    {intl l='ID'}{intl l='Content title'}{intl l="Actions"}
    {$ID} + {$TITLE} + +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.product.content.delete"} + + + + {/loop} +
    +
    +
    + {intl l="This product contains no contents"} +
    +
    +
    + + {* -- End related content management ---- *} + + {* -- Begin accessories management ------ *} + +
    +
    +
    + +

    {intl l='Product accessories'}

    +

    {intl l='Define here this product\'s accessories'}

    + + + + + {ifloop rel="categories"} +
    + + + {intl l='Select a category to get its products'} +
    + +
    +
    + + + + +
    + + {intl l='Select a product and click (+) to add it as an accessory'} +
    + +
    +
    + {intl l="No available product in this category"} +
    +
    + + {/ifloop} + + {elseloop rel="categories"} +
    {intl l="No categories found"}
    + {/elseloop} + +
    +
    + + + + + + + + + + + {module_include location='product_accessories_table_header'} + + + + + + + {loop name="assigned_accessories" order="accessory" type="accessory" product="$product_id" backend_context="1" lang="$edit_language_id"} + + + + + + + + {module_include location='product_accessories_table_row'} + + + + {/loop} + + {elseloop rel="assigned_accessories"} + + + + {/elseloop} + +
    {intl l='ID'}{intl l='Accessory title'}{intl l='Position'}{intl l="Actions"}
    {$ID} + {$TITLE} + + {admin_position_block + permission="admin.products.edit" + path={url path='/admin/products/update-accessory-position' product_id=$ID} + url_parameter="accessory_id" + in_place_edit_class="accessoryPositionChange" + position=$POSITION + id=$ID + } + +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.product.accessory.delete"} + + + + {/loop} +
    +
    +
    + {intl l="This product contains no accessories"} +
    +
    +
    + + {* -- End accessories management -------- *} + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + {/loop} +
    +
    +
    + + +{* Delete related content confirmation dialog *} + +{capture "delete_content_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_content_dialog" + dialog_title = {intl l="Remove related content"} + dialog_message = {intl l="Do you really want to remove this related content from the product ?"} + + form_action = {url path='/admin/products/related-content/delete'} + form_content = {$smarty.capture.delete_content_dialog nofilter} +} + +{* Delete accessory confirmation dialog *} + +{capture "delete_accessory_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_accessory_dialog" + dialog_title = {intl l="Remove an accessory"} + dialog_message = {intl l="Do you really want to remove this accessory from the product ?"} + + form_action = {url path='/admin/products/accessory/delete'} + form_content = {$smarty.capture.delete_accessory_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + +{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + +{/javascripts} + + + + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/profile-edit.html b/templates/admin/default/profile-edit.html new file mode 100644 index 000000000..e882dc40d --- /dev/null +++ b/templates/admin/default/profile-edit.html @@ -0,0 +1,126 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit profile'}{/block} + +{block name="check-permissions"}admin.profile.edit{/block} + +{block name="main-content"} +
    + +
    + + + +
    +
    + +
    + {intl l="Edit profile $NAME"} +
    + +
    + {form name="thelia.admin.profile.modification"} +
    + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='firstname'} +
    + + +
    + {/form_field} + + {form_field form=$form field='lastname'} +
    + + +
    + {/form_field} + + {form_field form=$form field='default_language'} +
    + + + +
    + {/form_field} + + {form_field form=$form field='editing_language_default'} +
    + + + +
    + {/form_field} + +
    +
    {intl l="Change password"}
    + + {form_field form=$form field='old_password'} +
    + + +
    + {/form_field} + + {form_field form=$form field='password'} +
    + + +
    + {/form_field} + + {form_field form=$form field='password_confirm'} +
    + + +
    + {/form_field} +
    + +
    + +
    +
    + {/form} +
    + +
    + +
    + +
    +
    +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + + {/javascripts} + {javascripts file='assets/js/main.js'} + + {/javascripts} + +{/block} \ No newline at end of file diff --git a/templates/admin/default/shipping-configuration-edit.html b/templates/admin/default/shipping-configuration-edit.html new file mode 100644 index 000000000..b17dc6de4 --- /dev/null +++ b/templates/admin/default/shipping-configuration-edit.html @@ -0,0 +1,138 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit a shipping configuration'}{/block} + +{block name="check-permissions"}admin.configuration.shipping-configuration.edit{/block} + +{block name="main-content"} +
    + +
    + + + +
    +
    +
    + +
    + {intl l='Edit shipping configuration %title' title=$TITLE} +
    + +
    +
    + + + +
    + + +
    + + + + +
    + +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="Country"}{intl l="Actions"}
    Wallis-et-Futuna + + + +
    Polynésie française + + + +
    USA - Alabama + + + +
    +
    + +
    + + + + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    + + {* Delete related content confirmation dialog *} + + {capture "delete_country_dialog"} + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_country_dialog" + dialog_title = {intl l="Remove country"} + dialog_message = {intl l="Do you really want to remove this country ?"} + + form_action = {url path=''} + form_content = {$smarty.capture.delete_country_dialog nofilter} + } +{/block} + +{block name="javascript-initialization"} + {javascripts file='assets/js/main.js'} + + {/javascripts} + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + + {/javascripts} +{/block} \ No newline at end of file diff --git a/templates/admin/default/shipping-configuration.html b/templates/admin/default/shipping-configuration.html new file mode 100644 index 000000000..067256d5f --- /dev/null +++ b/templates/admin/default/shipping-configuration.html @@ -0,0 +1,166 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Thelia Shipping configuration'}{/block} + +{block name="check-permissions"}admin.configuration.shipping-configuration.view{/block} + +{block name="main-content"} +
    + +
    + + + + {module_include location='shipping_configuration_top'} + +
    +
    +
    +
    + + + + + + + {module_include location='shipping_configuration_table_header'} + + + + + + + + + + {module_include location='shipping_configuration_table_row'} + + + + + + + {module_include location='shipping_configuration_table_row'} + + + + + + + {module_include location='shipping_configuration_table_row'} + + + + +
    + {intl l='Thelia Shipping configuration'} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.shipping-configuration.create"} + + + + {/loop} +
    {intl l="Description"}{intl l="Actions"}
    France + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"} + + {/loop} + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"} + + {/loop} +
    + {else} + + {/if} +
    Outre-Mer DOM + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"} + + {/loop} + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"} + + {/loop} +
    + {else} + + {/if} +
    Outre-Mer TOM + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"} + + {/loop} + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"} + + {/loop} +
    + {else} + + {/if} +
    +
    +
    +
    +
    + + {module_include location='shipping_configuration_bottom'} + +
    +
    + + {* Adding a new Shipping configuration *} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "creation_dialog"} + + +
    + + +
    + + + {module_include location='shipping_configuration_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "creation_dialog" + dialog_title = {intl l="Create a new shipping configuration"} + dialog_body = {$smarty.capture.creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this shipping configuration"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path='/admin/configuration/configuration/shipping_configuration/create'} + form_enctype = '' + form_error_message = $form_error_message + } + + {* Delete confirmation dialog *} + + {capture "delete_dialog"} + + + {module_include location='shipping_configuration_delete_form'} + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete shipping configuration"} + dialog_message = {intl l="Do you really want to delete this shipping configuration ?"} + + form_action = {url path='/admin/configuration/shipping_configuration/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} + } +{/block} \ No newline at end of file diff --git a/templates/admin/default/shipping-zones-edit.html b/templates/admin/default/shipping-zones-edit.html new file mode 100644 index 000000000..c330f9064 --- /dev/null +++ b/templates/admin/default/shipping-zones-edit.html @@ -0,0 +1,122 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit a shipping zone'}{/block} + +{block name="check-permissions"}admin.configuration.shipping-zones.edit{/block} + +{block name="main-content"} +
    + +
    + + + +
    +
    +
    + +
    + {intl l='Edit shipping zone %title' title=$TITLE} +
    + +
    +
    + +
    + + +
    + + + + +
    + +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    {intl l="Zones"}{intl l="Actions"}
    France + + + +
    Zone 1 + + + +
    Zone 2 + + + +
    +
    +
    +
    + +
    +
    +
    + +
    +
    + + {* Delete related content confirmation dialog *} + + {capture "delete_zone_dialog"} + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_zone_dialog" + dialog_title = {intl l="Remove zone"} + dialog_message = {intl l="Do you really want to remove this zone ?"} + + form_action = {url path=''} + form_content = {$smarty.capture.delete_zone_dialog nofilter} + } +{/block} + +{block name="javascript-initialization"} + {javascripts file='assets/js/main.js'} + + {/javascripts} + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + + {/javascripts} +{/block} \ No newline at end of file diff --git a/templates/admin/default/shipping-zones.html b/templates/admin/default/shipping-zones.html new file mode 100644 index 000000000..20ffef799 --- /dev/null +++ b/templates/admin/default/shipping-zones.html @@ -0,0 +1,121 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Thelia Shipping zones'}{/block} + +{block name="check-permissions"}admin.configuration.shipping-zones.view{/block} + +{block name="main-content"} +
    + +
    + + + + {module_include location='shipping_zones_top'} + +
    +
    +
    +
    + + + + + + + {module_include location='shipping_zones_table_header'} + + + + + + + + + + {module_include location='shipping_zones_table_row'} + + + + + + + {module_include location='shipping_zones_table_row'} + + + + + + + {module_include location='shipping_zones_table_row'} + + + + +
    + {intl l='Thelia Shipping zones'} +
    {intl l="Name"}{intl l="Actions"}
    So Colissimo + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"} + + {/loop} +
    + {else} + + {/if} +
    Chronopost + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"} + + {/loop} +
    + {else} + + {/if} +
    Kiala + {if ! $SECURED} +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"} + + {/loop} +
    + {else} + + {/if} +
    +
    +
    +
    +
    + + {module_include location='shipping_zones_bottom'} + +
    +
    + + {* Delete confirmation dialog *} + + {capture "delete_dialog"} + + + {module_include location='shipping_zones_delete_form'} + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete shipping zone"} + dialog_message = {intl l="Do you really want to delete this shipping zone ?"} + + form_action = {url path='/admin/configuration/shipping_zones/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} + } +{/block} \ No newline at end of file diff --git a/templates/admin/default/template-edit.html b/templates/admin/default/template-edit.html new file mode 100644 index 000000000..7b9ddd4aa --- /dev/null +++ b/templates/admin/default/template-edit.html @@ -0,0 +1,115 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit a template'}{/block} + +{block name="check-permissions"}admin.configuration.templates.edit{/block} + +{block name="main-content"} +
    + +
    + + {loop name="template_edit" type="template" id="$template_id" backend_context="1" lang="$edit_language_id"} + + + +
    +
    +
    + +
    + {intl l="Edit template $NAME"} +
    + +
    +
    + + {form name="thelia.admin.template.modification"} +
    + + {* Be sure to get the template ID, even if the form could not be validated *} + + + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/templates'}"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='name'} +
    + + +
    + {/form_field} +
    + {/form} +
    +
    + +
    +
    +
    +

    {intl l='Attributes'}

    +

    Manage attributes included in this product templates

    + +
    +
    +
    + +
    + +
    +

    {intl l='Features'}

    +

    Manage features included in this product templates

    + +
    +
    +
    +
    +
    +
    + +
    +
    + +
    + + {/loop} + + {elseloop rel="template_edit"} +
    +
    +
    + {intl l="Sorry, template ID=$template_id was not found."} +
    +
    +
    + {/elseloop} + +
    +
    +{/block} + +{block name="javascript-initialization"} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/templates.html b/templates/admin/default/templates.html new file mode 100644 index 000000000..f7e912e9c --- /dev/null +++ b/templates/admin/default/templates.html @@ -0,0 +1,217 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Thelia Product Templates'}{/block} + +{block name="check-permissions"}admin.configuration.templates.view{/block} + +{block name="main-content"} +
    + +
    + + + + {module_include location='templates_top'} + +
    +
    +
    +
    + + {if ! empty($general_error) } +
    {$general_error}
    + {/if} + +
    + + + + + + + + + {module_include location='templates_table_header'} + + + + + + + {loop name="list" type="template" backend_context="1" lang=$lang_id order=$order} + + + + + + {module_include location='templates_table_row'} + + + + {/loop} + + {elseloop rel="list"} + + + + {/elseloop} + +
    + {intl l='Thelia product templates'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.templates.create"} + + + + {/loop} +
    + {admin_sortable_header + current_order=$order + order='id' + reverse_order='id_reverse' + path='/admin/configuration/templates' + label="{intl l='ID'}" + } + + {admin_sortable_header + current_order=$order + order='alpha' + reverse_order='alpha_reverse' + path='/admin/configuration/templates' + label="{intl l='Title'}" + } + {intl l="Actions"}
    {$ID} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.templates.change"} + {$NAME} + {/loop} + {elseloop rel="can_change"} + {$NAME} + {/elseloop} + +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.templates.change"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.templates.delete"} + + {/loop} +
    +
    +
    + {intl l="No product template has been created yet. Click the + button to create one."} +
    +
    +
    +
    +
    +
    +
    + + {module_include location='templates_bottom'} + +
    +
    + +{* Adding a new template *} + +{form name="thelia.admin.template.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "creation_dialog"} + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created template ID, see controller *} + + {/form_field} + + {form_field form=$form field='name'} +
    + + + {loop type="lang" name="default-lang" default_only="1"} +
    + + {intl l=$TITLE} +
    + +
    {intl l="Enter here the template name in the default language ($TITLE)"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {module_include location='template_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "creation_dialog" + dialog_title = {intl l="Create a new product template"} + dialog_body = {$smarty.capture.creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this product template"} + + form_action = {url path='/admin/configuration/templates/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* Delete confirmation dialog *} + +{capture "delete_dialog"} + + + {module_include location='template_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete template"} + dialog_message = {intl l="Do you really want to delete this template ? It will be removed from all products."} + + form_action = {url path='/admin/configuration/templates/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/variable-edit.html b/templates/admin/default/variable-edit.html index 7e634b92a..30d9ea7c5 100644 --- a/templates/admin/default/variable-edit.html +++ b/templates/admin/default/variable-edit.html @@ -45,7 +45,7 @@ {* We do not allow creation of hidden variables *} {form_field form=$form field='id'} - + {/form_field} {form_field form=$form field='hidden'} @@ -61,14 +61,14 @@ {form_field form=$form field='name'}
    - +
    {/form_field} {form_field form=$form field='value'}
    - +
    {/form_field} diff --git a/templates/admin/default/variables.html b/templates/admin/default/variables.html index 3f1e90a09..0ce47727d 100644 --- a/templates/admin/default/variables.html +++ b/templates/admin/default/variables.html @@ -21,6 +21,7 @@
    +
    {intl l='Thelia system variables'} @@ -95,7 +96,7 @@ {if $SECURED} {$VALUE} {else} - + {/if} @@ -122,6 +123,7 @@ {/loop}
    +
    diff --git a/templates/default/account.html b/templates/default/account.html index 94bd58501..187847ced 100644 --- a/templates/default/account.html +++ b/templates/default/account.html @@ -1,11 +1,14 @@ -{check_auth context="front" roles="CUSTOMER" login_tpl="login"} {extends file="layout.tpl"} +{block name="no-return-functions"} + {check_auth context="front" roles="CUSTOMER" login_tpl="login"} +{/block} + {block name="breadcrumb"} diff --git a/templates/default/address-update.html b/templates/default/address-update.html index d1dc7ca5f..9e58e19ac 100644 --- a/templates/default/address-update.html +++ b/templates/default/address-update.html @@ -1,10 +1,14 @@ -{check_auth context="front" roles="CUSTOMER" login_tpl="login"} {extends file="layout.tpl"} + +{block name="no-return-functions"} + {check_auth context="front" roles="CUSTOMER" login_tpl="login"} +{/block} + {block name="breadcrumb"}
    +{/block} diff --git a/templates/default/includes/categories-filters.html b/templates/default/includes/categories-filters.html new file mode 100644 index 000000000..6a9425a66 --- /dev/null +++ b/templates/default/includes/categories-filters.html @@ -0,0 +1,77 @@ +
    +

    Find a product

    +
    +
    +
    + Type +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + Price +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + Size +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    \ No newline at end of file diff --git a/templates/default/includes/category-toolbar.html b/templates/default/includes/category-toolbar.html new file mode 100644 index 000000000..b3a6c7daa --- /dev/null +++ b/templates/default/includes/category-toolbar.html @@ -0,0 +1,67 @@ + diff --git a/templates/default/includes/menu.html b/templates/default/includes/menu.html new file mode 100644 index 000000000..083c74ef2 --- /dev/null +++ b/templates/default/includes/menu.html @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/templates/default/includes/single-product.html b/templates/default/includes/single-product.html new file mode 100644 index 000000000..bca37f80b --- /dev/null +++ b/templates/default/includes/single-product.html @@ -0,0 +1,65 @@ +
  • +
    + + {loop name="brand.feature" type="feature" product=$ID title="brand"} + {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} + + {/loop} + {/loop} + {loop name="brand.feature" type="feature" product=$ID title="isbn"} + {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} + + {/loop} + {/loop} + + + +
    +

    {$TITLE}

    + {if $hasDescription} +
    +

    {$DESCRIPTION}

    +
    + {/if} +
    + +
    +
    + + + + + + {if $IS_PROMO } + {loop name="productSaleElements_promo" type="product_sale_elements" product=$ID limit="1" order="min_price"} + {assign var="default_product_sale_elements" value=$ID} + {intl l="Special Price:"} {format_number number=$TAXED_PROMO_PRICE} {currency attr="symbol"} + {intl l="Regular Price:"} {format_number number=$TAXED_PRICE} {currency attr="symbol"} + {/loop} + {else} + {format_number number=$BEST_TAXED_PRICE} {currency attr="symbol"} + {/if} + +
    + {if $hasBtn} +
    + +
    + {/if} +
    +
    +
  • \ No newline at end of file diff --git a/templates/default/index.html b/templates/default/index.html index 39205497c..390f06965 100644 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -34,13 +34,22 @@
  • - - + {$product_id=$ID} + {loop name="brand.feature" type="feature" product="{$ID}" title="brand"} + {loop name="brand.value" type="feature_value" feature="{$ID}" product="$product_id"} + + {/loop} + {/loop} + {loop name="brand.feature" type="feature" product=$ID title="isbn"} + {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} + + {/loop} + {/loop} @@ -90,51 +100,7 @@
    diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 1865acc24..4aba10120 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -1,3 +1,4 @@ +{block name="no-return-functions"}{/block} diff --git a/templates/default/order_delivery.html b/templates/default/order_delivery.html new file mode 100644 index 000000000..46a5be64e --- /dev/null +++ b/templates/default/order_delivery.html @@ -0,0 +1,182 @@ +{extends file="layout.tpl"} + +{block name="no-return-functions"} + {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_cart_not_empty} +{/block} + +{block name="breadcrumb"} + +{/block} + +{block name="main-content"} +
    +
    + +

    Your Cart

    + + + + {form name="thelia.order.delivery"} +
    + + {form_hidden_fields form=$form} + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='delivery-address'} + +
    +
    + Add a new address + Chose your delivery address + {if $error} + {$message} + {/if} +
    +
    + + + + {loop type="address" name="customer.addresses" customer="current"} + + + + + + + + + {/loop} + + + +
    +
    + + {/form_field} + + {form_field form=$form field='delivery-module'} + +
    +
    + Choose your delivery method + {if $error} + {$message} + {/if} +
    +
    + {loop type="delivery" name="deliveries" force_return="true"} +
    + +
    + {/loop} +
    +
    + + {/form_field} + + Back + + +
    + {/form} + +
    +
    + + + +{/block} + +{block name="javascript-initialization"} + +{/block} \ No newline at end of file diff --git a/templates/default/order_invoice.html b/templates/default/order_invoice.html new file mode 100644 index 000000000..6a5b493a4 --- /dev/null +++ b/templates/default/order_invoice.html @@ -0,0 +1,325 @@ +{extends file="layout.tpl"} + +{block name="no-return-functions"} + {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_cart_not_empty} + {check_valid_delivery} +{/block} + +{block name="breadcrumb"} + +{/block} + +{block name="main-content"} +
    +
    + +

    Your Cart

    + + + + {form name="thelia.order.payment"} + +
    + + {form_hidden_fields form=$form} + + {if $form_error}
    {$form_error_message}
    {/if} + + + + + + + + + + + + + + + + + + + + {loop type="cart" name="cartloop"} + + + + + + + + + + {/loop} + + + + + + + + + + + + + + + + + +
      + + Name + + + Price + + + Quantity + + + Total +
    + + + {assign "cart_count" $LOOP_COUNT} + {ifloop rel='product-image'} + {loop type="image" name="product-image" product=$PRODUCT_ID limit="1" width="118" height="85" force_return="true"} + Product #{$cart_count} + {/loop} + {/ifloop} + {elseloop rel="product-image"} + {images file='assets/img/product/1/118x85.png'}Product #{$cart_count}{/images} + {/elseloop} + +

    + Product #{$cart_count} +

    +
    +
    +
    Available :
    +
    In Stock
    +
    No.
    +
    {$REF}
    + {*
    Select Size
    +
    Large
    +
    Select Delivery Date
    +
    Jan 2, 2013
    +
    Additional Option
    +
    Option 1
    *} +
    +
    +
    + {if $IS_PROMO == 1} + {assign "real_price" $PROMO_TAXED_PRICE} +
    {currency attr="symbol"} {$PROMO_TAXED_PRICE}
    + instead of {currency attr="symbol"} {$TAXED_PRICE} + {else} + {assign "real_price" $TAXED_PRICE} +
    {currency attr="symbol"} {$TAXED_PRICE}
    + {/if} +
    + {$QUANTITY} + + {currency attr="symbol"} {$real_price * $QUANTITY} +
     Shipping Tax +
    + {currency attr="symbol"} {order attr="postage"} +
    +
    +
    + + + + +
    +
    Total TTC +
    + {currency attr="symbol"} {{cart attr="total_taxed_price"} + {order attr="postage"}} +
    +
    + +
    +
    + {loop type="address" name="delivery-address" id="{order attr="delivery_address"}"} +
    Delivery address
    +
    + {loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords} + {$COMPANY} +
    + {$ADDRESS1}
    + {if $ADDRESS2 != ""} + {$ADDRESS2}
    + {/if} + {if $ADDRESS3 != ""} + {$ADDRESS3}
    + {/if} + {$ZIPCODE} + {$CITY}, {loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop} +
    +
    + {/loop} +
    + + {form_field form=$form field='invoice-address'} + +
    +
    Billing address
    + + {if $error} + {$message} + {/if} + +
    + + + + {loop type="address" name="invoice-address" default="{if !$error && $value}*{else}true{/if}" id="{if !$error && $value}{$value}{else}*{/if}"} + + + + + + + {if !$error} + + + + {/if} + + {/loop} + + {loop type="address" name="invoice-address" default="{if !$error && $value}*{else}false{/if}" exclude="{if !$error && $value}{$value}{else}none{/if}"} + + + + + + + {/loop} + +
    + {loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords} + {$COMPANY} +
    + {$ADDRESS1}
    + {if $ADDRESS2 != ""} + {$ADDRESS2}
    + {/if} + {if $ADDRESS3 != ""} + {$ADDRESS3}
    + {/if} + {$ZIPCODE} + {$CITY}, {loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop} +
    +
    + +
    + Change address +
    + {loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords} + {$COMPANY} +
    + {$ADDRESS1}
    + {if $ADDRESS2 != ""} + {$ADDRESS2}
    + {/if} + {if $ADDRESS3 != ""} + {$ADDRESS3}
    + {/if} + {$ZIPCODE} + {$CITY}, {loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop} +
    +
    + +
    + +
    + +
    +
    + + {/form_field} + + {form_field form=$form field='payment-module'} + +
    +
    Choose your payment method
    + + {if $error} + {$message} + {/if} + +
    +
      + + {loop type="payment" name="payments" force_return="true"} + + {assign "paymentModuleId" $ID} + + {loop type="image" name="paymentspicture" source="module" source_id=$ID force_return="true" width="100" height="72"} + +
    • +
      + +
      +
    • + + {/loop} + + {/loop} + +
    +
    + + {/form_field} + + Back + +
    + + {/form} + + +
    + + + +
    +{/block} + +{block name="javascript-initialization"} + +{/block} \ No newline at end of file diff --git a/templates/default/order_placed.html b/templates/default/order_placed.html new file mode 100644 index 000000000..281800bb5 --- /dev/null +++ b/templates/default/order_placed.html @@ -0,0 +1,64 @@ +{extends file="layout.tpl"} + +{block name="breadcrumb"} + +{/block} + +{block name="main-content"} +
    +
    + +

    Your Cart

    + + + + {loop type="order" name="placed-order" id=$placed_order_id} + +
    +
    +

    You chose to pay by : {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}

    +
    +
    +

    Thank you for the trust you place in us.

    +

    A summary of your order email has been sent to the following address: {customer attr="email"}

    +

    Your order will be confirmed by us upon receipt of your payment.

    + +
    +
    Order number :
    +
    {$REF}
    +
    Date :
    +
    {format_date date=$CREATE_DATE output="date"}
    +
    Total :
    +
    {loop type="currency" name="order-currency" id=$CURRENCY}{$SYMBOL}{/loop} {$TOTAL_TAXED_AMOUNT}
    +
    +
    +
    + + {/loop} + + Go home + +
    + +
    +{/block} + +{block name="javascript-initialization"} + +{/block} \ No newline at end of file diff --git a/templates/default/password.html b/templates/default/password.html index ec472a1f9..9168bd0a3 100644 --- a/templates/default/password.html +++ b/templates/default/password.html @@ -4,7 +4,7 @@ diff --git a/templates/default/product.html b/templates/default/product.html new file mode 100644 index 000000000..dc89eb03b --- /dev/null +++ b/templates/default/product.html @@ -0,0 +1,225 @@ +{extends file="layout.tpl"} + +{block name="breadcrumb"} + +{/block} + +{block name="main-content"} +
    + {loop name="product.details" type="product" id="{product attr="id"}"} +
    + + + {loop name="brand.feature" type="feature" product="{$ID}" title="brand"} + {loop name="brand.value" type="feature_value" feature="{$ID}" product="{product attr="id"}"} + + {/loop} + {/loop} + {loop name="brand.feature" type="feature" product=$ID title="isbn"} + {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} + + {/loop} + {/loop} + + + +
    +
    +

    {$TITLE}

    + {intl l='Ref.'}: {$REF} + +
    +

    {$POSTSCRIPTUM}

    +
    +
    + + +
    +
    {intl l="Availability"}: In stock
    + +
    + {loop type="category" name="category_tag" id=$DEFAULT_CATEGORY} + + {/loop} + + + + + {if $IS_PROMO } + {loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1" order="min_price"} + {assign var="default_product_sale_elements" value="$ID"} + {intl l="Special Price:"} {format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"} + {intl l="Regular Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} + {/loop} + {else} + {format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"} + {/if} +
    +
    + + {form name="thelia.cart.add" } +
    + {form_hidden_fields form=$form} + + + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='product_sale_elements_id'} + {if $default_product_sale_elements } + + {else} + {loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1"} + + {/loop} + {/if} + {/form_field} + {form_field form=$form field="product"} + + {/form_field} +
    +
    + +
    + +
    +
    + +
    +
    + Size +
    + + + +
    +
    +
    +
    +
    + {form_field form=$form field='quantity'} +
    + + + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
    + {/form_field} + +
    + +
    +
    +
    + {/form} +
    + +
    + +
    +
    +

    {$DESCRIPTION}

    +
    +
    + {ifloop rel="feature_value_info"} +
      + {loop name="feature_info" type="feature" product="{$ID}"} +
    • {$TITLE} : + {loop name="feature_value_info" type="feature_value" feature="{$ID}" product="{product attr="id"}"} + {$TITLE} + {/loop} +
    • + {/loop} +
    + {/ifloop} +
    +
    +
    +
    + {/loop} +
    + +
    +{/block} \ No newline at end of file diff --git a/templates/default/register.html b/templates/default/register.html index a3448932b..ad7945457 100644 --- a/templates/default/register.html +++ b/templates/default/register.html @@ -4,7 +4,7 @@ diff --git a/templates/install/index.html b/templates/install/index.html deleted file mode 100644 index a996cc241..000000000 --- a/templates/install/index.html +++ /dev/null @@ -1,12 +0,0 @@ -{extends file="layout.html"} -{block name="content"} -

    {intl l="Thelia installation wizard"}

    -
    - - {intl l="Bienvenue au sein du programme d'installation de Thelia."}
    - {intl l="Nous allons vous guider tout au long de ce processus afin d'installer l'application sur votre système."}

    - -
    - -
    -{/block} \ No newline at end of file diff --git a/templates/install/layout.html b/templates/install/layout.html deleted file mode 100644 index 0a13586ad..000000000 --- a/templates/install/layout.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - {block name="title"}Thelia Install{/block} - - {images file='../admin/default/assets/img/favicon.ico'}{/images} - - - - {stylesheets file='../admin/default/assets/bootstrap/css/bootstrap.css' filters='cssembed'} - - {/stylesheets} - - {stylesheets file='../admin/default/assets/bootstrap/css/bootstrap-responsive.css' filters='cssembed'} - - {/stylesheets} - - - {stylesheets file='../admin/default/assets/css/*' filters='less,cssembed'} - - {/stylesheets} - - - -
    -
    -
    {intl l='Version %ver' ver="{$THELIA_VERSION}"}
    -
    -
    -
    - {block name="content"}{/block} -
    - -
    - - - - \ No newline at end of file diff --git a/tests/functionnal/casperjs/exe/00_parameters.js b/tests/functionnal/casperjs/exe/00_parameters.js index a32ee89b5..df5470229 100644 --- a/tests/functionnal/casperjs/exe/00_parameters.js +++ b/tests/functionnal/casperjs/exe/00_parameters.js @@ -3,7 +3,7 @@ casper.test.comment('Please edit 00_parameters.js to add your configuration'); var thelia2_login_admin_url = thelia2_base_url + 'admin/login'; var thelia2_login_coupon_list_url = thelia2_base_url + 'admin/login'; -var thelia2_login_coupon_create_url = thelia2_base_url + 'admin/coupon/create'; +var thelia2_login_coupon_create_url = thelia2_base_url + 'admin/coupon/create/'; var thelia2_login_coupon_read_url = thelia2_base_url + 'admin/coupon/read/1'; var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1'; diff --git a/tests/functionnal/casperjs/exe/30_coupons.js b/tests/functionnal/casperjs/exe/30_coupons.js index 2ac04a759..2147c14cf 100644 --- a/tests/functionnal/casperjs/exe/30_coupons.js +++ b/tests/functionnal/casperjs/exe/30_coupons.js @@ -1,51 +1,151 @@ -casper.test.comment('Testing coupons'); +// +//var casper = require('casper').create({ +// viewportSize:{ +// width:1024, height:768 +// }, +// pageSettings:{ +// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11' +// }, +// verbose:true +//}); +casper.test.comment('Testing coupons'); ////LIST // @todo implement ////CREATE -// @todo implement - -//UPDATE COUPON RULE -casper.start(thelia2_login_coupon_update_url, function() { +casper.start(thelia2_login_coupon_create_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png'); - this.echo('\nCOUPON RULE - EDIT'); - this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); -// this.test.assertSelectorHasText('#content-header > h1', 'Liste des pays', 'Web page main content OK'); - this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1st default rule found'); - this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2nd default rule found'); + this.test.comment('COUPON - CREATE EMPTY'); - // Create rule + // Click on is unlimited button + this.click("form #is-unlimited"); + this.sendKeys('input#max-usage', '-2'); + + // cleaning expiration date default value this.evaluate(function() { - $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); + $("#expiration-date").val('').change(); return true; }); - this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); + + this.capture('tests/functionnal/casperjs/screenshot/coupons/creating-new-coupon.png'); + this.click("form .control-group .btn.btn-default.btn-primary"); + }); casper.wait(1000, function() { this.echo("\nWaiting...."); }); +// Test Coupon creation if no input casper.then(function(){ - this.evaluate(function() { - $('#quantity-operator').val('>=').change(); - return true; - }); - this.sendKeys('input#quantity-value', '4'); - this.click('#constraint-save-btn'); + this.test.assertHttpStatus(200); + this.capture('tests/functionnal/casperjs/screenshot/coupons/created-new-empty-coupon.png'); + this.test.assertExists('.has-error #code', 'Error on code input found'); + this.test.assertExists('.has-error #title', 'Error on title input found'); + + this.test.assertExists('.has-error #expiration-date', 'Error on expiration date input found'); + this.test.assertExists('.has-error #max-usage', 'Error on max usage input found'); + this.test.assertExists('.has-error #description', 'Error on description input found'); + this.test.assertExists('.has-error #effect', 'Error on effect input found'); + this.test.assertExists('.has-error #amount', 'Error on amount input found'); + this.test.assertExists('.has-error #short-description', 'Error on short-description input found'); }); -casper.wait(1000, function() { +// Test Coupon creation if good input +casper.then(function(){ + + this.sendKeys('input#code', 'XMAS10'); + this.sendKeys('input#title', 'christmas'); + this.click("form #is-enabled"); + this.click("form #is-available-on-special-offers"); + this.click("form #is-cumulative"); + this.click("form #is-removing-postage"); + + this.evaluate(function() { + $("#expiration-date").val('2013-11-14').change(); + return true; + }); + + // Click on is unlimited button + this.click("form #is-unlimited"); + this.sendKeys('input#max-usage', '40'); + + this.evaluate(function() { + $('#effect').val('thelia.coupon.type.remove_x_amount').change(); + return true; + }); + + this.test.assertSelectorHasText( + '#effectToolTip', + this.evaluate(function () { + return $("#effect option[value^='thelia.coupon.type.remove_x_amount']").attr('data-description'); + }), + 'Tooltip found' + ); + this.sendKeys('input#amount', '42.12'); + this.sendKeys('#short-description', 'Mauris sed risus imperdiet, blandit arcu ac, tempus metus. Aliquam erat volutpat. Nullam dictum sed.'); + this.sendKeys('#description', 'Etiam sodales non nisi a condimentum. Morbi luctus mauris mattis sem ornare; ac blandit tortor porta! Sed vel viverra dolor. Nulla eget viverra eros. Donec rutrum felis ut quam blandit, eu massa nunc.'); + + this.capture('tests/functionnal/casperjs/screenshot/coupons/coupon-created-ready-to-be-saved.png'); + this.click("#save-coupon-btn"); +}); + +casper.wait(2000, function() { this.echo("\nWaiting...."); }); +// Test Coupon creation if good input is well saved casper.then(function(){ - this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); - this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equals to 4','3rd rule found'); -}); + this.test.assertHttpStatus(302); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/created-new-coupon.png'); + this.test.assertField('thelia_coupon_creation[code]', 'XMAS10', 'Code found'); + this.test.assertField('thelia_coupon_creation[title]', 'christmas', 'Title found'); + this.test.assert(this.evaluate(function () { + return document.getElementById('is-enabled').checked; + }), 'Checkbox is enabled checked'); + this.test.assert(this.evaluate(function () { + return document.getElementById('is-available-on-special-offers').checked; + }), 'Checkbox is available on special offers checked'); + this.test.assert(this.evaluate(function () { + return document.getElementById('is-cumulative').checked; + }), 'Checkbox is cumulative checked'); + this.test.assert(this.evaluate(function () { + return document.getElementById('is-removing-postage').checked; + }), 'Checkbox is cumulative checked'); + + this.test.assertField('thelia_coupon_creation[expirationDate]', '2013-11-14', 'Expiration date found'); + this.test.assertField('thelia_coupon_creation[maxUsage]', '40', 'Max usage found'); + this.test.assert(this.evaluate(function () { + return !document.getElementById('is-unlimited').checked; + }), 'Checkbox is unlimited not checked'); + + this.test.assert( + this.evaluate(function () { + return $("#effect").val(); + }), + 'thelia.coupon.type.remove_x_amount', + 'Effect found' + ); + this.test.assertSelectorHasText( + '#effectToolTip', + this.evaluate(function () { + return $("#effect option[value^='thelia.coupon.type.remove_x_amount']").attr('data-description'); + }), + 'Tooltip found' + ); + this.test.assertField('thelia_coupon_creation[amount]', '42.12', 'Amount found'); + + this.test.assertField('thelia_coupon_creation[shortDescription]', 'Mauris sed risus imperdiet, blandit arcu ac, tempus metus. Aliquam erat volutpat. Nullam dictum sed.', 'Short description found'); + this.test.assertField('thelia_coupon_creation[description]', 'Etiam sodales non nisi a condimentum. Morbi luctus mauris mattis sem ornare; ac blandit tortor porta! Sed vel viverra dolor. Nulla eget viverra eros. Donec rutrum felis ut quam blandit, eu massa nunc.', 'Description found'); + + +}); ////EDIT CHECK // @todo implement diff --git a/tests/functionnal/casperjs/exe/31_coupons_rule.js b/tests/functionnal/casperjs/exe/31_coupons_rule.js new file mode 100644 index 000000000..66706aada --- /dev/null +++ b/tests/functionnal/casperjs/exe/31_coupons_rule.js @@ -0,0 +1,312 @@ +//// +////var casper = require('casper').create({ +//// viewportSize:{ +//// width:1024, height:768 +//// }, +//// pageSettings:{ +//// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11' +//// }, +//// verbose:true +////}); +// +//casper.test.comment('Testing coupons rules'); +// +////UPDATE COUPON RULE +//casper.start(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png'); +// this.test.comment('COUPON RULE - EDIT'); +// this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found'); +// +// // Create rule +// this.evaluate(function() { +// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); +// return true; +// }); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); +//}); +// +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +// +//// Test Rule updating +//casper.then(function(){ +// this.evaluate(function() { +// $('#quantity-operator').val('>=').change(); +// return true; +// }); +// this.sendKeys('input#quantity-value', '4'); +// this.click('#constraint-save-btn'); +//}); +// +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +// +//casper.then(function(){ +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found'); +// +// // Click on Edit button +// this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn'); +//}); +// +//casper.wait(2000, function() { +// this.echo("\nWaiting...."); +//}); +// +//casper.then(function(){ +// this.evaluate(function() { +// $('#quantity-operator').val('==').change(); +// return true; +// }); +// +// // Removing old value +//// casper.evaluate(function triggerKeyDownEvent() { +//// var e = $.Event("keydown"); +//// e.which = 8; +//// e.keyCode = 8; +//// $("#quantity-value").trigger(e); +//// }); +// this.evaluate(function() { +// $("#quantity-value").val('').change(); +// return true; +// }); +// +// // Adding new value +// this.sendKeys('#quantity-value', '5'); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png'); +// this.click('#constraint-save-btn'); +//}); +// +//casper.wait(2000, function() { +// this.echo("\nWaiting...."); +//}); +//// Check if updated rule has been saved and list refreshed +//casper.then(function(){ +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found'); +//}); +// +//// Check if updated rule has been well saved +//casper.thenOpen(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found'); +// +// // Click on Delete button +// this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn'); +//}); +// +//casper.wait(2000, function() { +// this.echo("\nWaiting...."); +//}); +// +//casper.then(function(){ +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found'); +// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found'); +//}); +// +//// Check if updated rule has been well saved +//casper.thenOpen(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found'); +// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found'); +//}); +// +//// Test creating rule that won't be edited +//casper.then(function(){ +//// Create rule +// this.evaluate(function() { +// $('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change(); +// return true; +// }); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png'); +//}); +// +//casper.wait(2000, function() { +// this.echo("\nWaiting...."); +//}); +// +//// Test Rule creation +//casper.then(function(){ +// this.evaluate(function() { +// $('#price-operator').val('<=').change(); +// return true; +// }); +// // Removing old value +//// casper.evaluate(function triggerKeyDownEvent() { +//// var e = $.Event("keydown"); +//// e.which = 8; +//// e.keyCode = 8; +//// $("input#price-value").trigger(e); +//// }); +// this.evaluate(function() { +// $("input#price-value").val('').change(); +// return true; +// }); +// +// // Changing 400 to 401 +// this.sendKeys('input#price-value', '401'); +// this.evaluate(function() { +// $('#currency-value').val('GBP').change(); +// return true; +// }); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png'); +// this.click('#constraint-save-btn'); +//}); +// +//casper.wait(2000, function() { +// this.echo("\nWaiting...."); +//}); +// +//casper.then(function(){ +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found'); +// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found'); +//}); +// +//// Check if created rule has been well saved +//casper.thenOpen(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found'); +// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found'); +//}); +// +//// Testing deleting all rules +//casper.then(function(){ +//// Click on Delete button +// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +//}); +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +//casper.then(function(){ +//// Click on Delete button +// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +//}); +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +//casper.then(function(){ +//// Click on Delete button +// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +//}); +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +//casper.then(function(){ +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found'); +// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +//}); +// +//// Check if created rule has been well saved +//casper.thenOpen(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found'); +// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +//}); +// +// +//// Test add no condition rule +//casper.then(function(){ +// this.evaluate(function() { +// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); +// return true; +// }); +//}); +// +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +// +//// Test Rule updating +//casper.then(function(){ +// this.evaluate(function() { +// $('#quantity-operator').val('>').change(); +// return true; +// }); +// this.sendKeys('input#quantity-value', '4'); +// this.click('#constraint-save-btn'); +//}); +// +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +// +//casper.then(function(){ +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found'); +// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +//}); +// +//// Check if created rule has been well saved +//casper.thenOpen(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found'); +// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +//}); +// +//casper.then(function(){ +// this.evaluate(function() { +// $('#category-rule').val('thelia.constraint.rule.available_for_everyone').change(); +// return true; +// }); +//}); +// +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +// +//// Test Rule updating +//casper.then(function(){ +// this.click('#constraint-save-btn'); +//}); +// +//casper.wait(1000, function() { +// this.echo("\nWaiting...."); +//}); +//casper.then(function(){ +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found'); +// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +//}); +// +//// Check if created rule has been well saved +//casper.thenOpen(thelia2_login_coupon_update_url, function() { +// this.test.assertHttpStatus(200); +// this.test.comment('Now on : ' + this.getCurrentUrl()); +// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); +// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found'); +// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +//}); +// +////RUN +//casper.run(function() { +// this.test.done(); +//}); \ No newline at end of file diff --git a/web/.htaccess b/web/.htaccess new file mode 100755 index 000000000..3840d727a --- /dev/null +++ b/web/.htaccess @@ -0,0 +1,12 @@ +Options +FollowSymlinks -Indexes + +AddDefaultCharset UTF-8 + + + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + + RewriteRule ^(.*)$ index.php [QSA,L] + \ No newline at end of file diff --git a/web/index_dev.php b/web/index_dev.php index bb90e6ab0..16c7d5f71 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -51,5 +51,7 @@ $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); -echo "\n"; -echo "\n"; +if (strstr($response->headers->get('content-type'), 'text/html') !== false) { + echo "\n"; + echo "\n"; +} diff --git a/web/install/bdd.php b/web/install/bdd.php new file mode 100755 index 000000000..05fcfe762 --- /dev/null +++ b/web/install/bdd.php @@ -0,0 +1,119 @@ +. */ +/* */ +/*************************************************************************************/ + +$step=4; +include("header.php"); + +if (isset($_POST['host']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['port'])){ + + $_SESSION['install']['host'] = $_POST['host']; + $_SESSION['install']['username'] = $_POST['username']; + $_SESSION['install']['password'] = $_POST['password']; + $_SESSION['install']['port'] = $_POST['port']; + + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_POST['host'], $_POST['username'], $_POST['password'], $_POST['port']); + if(! $checkConnection->exec() || $checkConnection->getConnection()->query('show databases') === false){ + header('location: connection.php?err=1'); + exit; + } +} +elseif($_SESSION['install']['step'] >=3) { + + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']); +} +else { + header('location: connection.php?err=1'); + exit; +} +$_SESSION['install']['step'] = 4; +$connection = $checkConnection->getConnection(); + +$databases = $connection->query('show databases'); +?> +
    +
    +
    + Choose your database +

    + The SQL server contains multiple databases.
    + Select below the one you want to use. +

    + + + exec(sprintf('use %s', $database['Database'])); + + $tables = $connection->query('SHOW TABLES'); + + $found = false; + foreach($tables as $table) { + if($table[0] == 'cart_item') { + $found = true; + break; + } + } + + ?> +
    + +
    + + exec('use information_schema'); + + $permissions = $connection->query("SELECT COUNT( * ) FROM `USER_PRIVILEGES` + WHERE PRIVILEGE_TYPE = 'CREATE' + AND GRANTEE LIKE '%".$_SESSION['install']['username']."%' + AND IS_GRANTABLE = 'YES';"); + + $writePermission = false; + if($permissions->fetchColumn(0) > 0) { + ?> +

    + or +

    + +
    + +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/web/install/bootstrap.php b/web/install/bootstrap.php new file mode 100755 index 000000000..522f6483b --- /dev/null +++ b/web/install/bootstrap.php @@ -0,0 +1,27 @@ +. */ +/* */ +/*************************************************************************************/ + +include __DIR__ . "/../../core/bootstrap.php"; + +$thelia = new \Thelia\Core\Thelia("install", false); +$thelia->boot(); \ No newline at end of file diff --git a/web/install/config.php b/web/install/config.php new file mode 100755 index 000000000..9ba221cdd --- /dev/null +++ b/web/install/config.php @@ -0,0 +1,110 @@ +. */ +/* */ +/*************************************************************************************/ + +$step = 5; +include("header.php"); +global $thelia; +$err = isset($_GET['err']) && $_GET['err']; + +if (!$err && $_SESSION['install']['step'] != $step) { + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']); + $connection = $checkConnection->getConnection(); + $connection->exec("SET NAMES UTF8"); + $database = new \Thelia\Install\Database($connection); + + if (isset($_POST['database'])) { + $_SESSION['install']['database'] = $_POST['database']; + } + + if (isset($_POST['database_create']) && $_POST['database_create'] != "") { + $_SESSION['install']['database'] = $_POST['database_create']; + $database->createDatabase($_SESSION['install']['database']); + } + + $database->insertSql($_SESSION['install']['database']); + + if(!file_exists(THELIA_ROOT . "/local/config/database.yml")) { + $fs = new \Symfony\Component\Filesystem\Filesystem(); + + $sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample"; + $configFile = THELIA_ROOT . "/local/config/database.yml"; + + $fs->copy($sampleConfigFile, $configFile, true); + + $configContent = file_get_contents($configFile); + + $configContent = str_replace("%DRIVER%", "mysql", $configContent); + $configContent = str_replace("%USERNAME%", $_SESSION['install']['username'], $configContent); + $configContent = str_replace("%PASSWORD%", $_SESSION['install']['password'], $configContent); + $configContent = str_replace( + "%DSN%", + sprintf("mysql:host=%s;dbname=%s;port=%s", $_SESSION['install']['host'], $_SESSION['install']['database'], $_SESSION['install']['port']), + $configContent + ); + + file_put_contents($configFile, $configContent); + + // FA - no, as no further install will be possible + // $fs->remove($sampleConfigFile); + + $fs->remove($thelia->getContainer()->getParameter("kernel.cache_dir")); + } +} + +$_SESSION['install']['step'] = $step; + +?> +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    + +
    +
    + +
    + + + diff --git a/web/install/connection.php b/web/install/connection.php new file mode 100755 index 000000000..fdbddfafd --- /dev/null +++ b/web/install/connection.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +$step = 3; +include("header.php"); +if(!$_SESSION['install']['continue'] && $_SESSION['install']['step'] == 2) { + header(sprintf('location: %s', $_SESSION['install']['return_step'])); +} + +$_SESSION['install']['step'] = 3; +?> + +
    + +
    Wrong connection information
    + +
    +
    + + +
    + +
    + + +
    + +
    + + +
    +
    + + +
    + +
    + +
    +
    + +
    + +
    +
    + + \ No newline at end of file diff --git a/web/install/end.php b/web/install/end.php new file mode 100755 index 000000000..a86c2d903 --- /dev/null +++ b/web/install/end.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ +$step=6; +include "header.php"; + +if($_SESSION['install']['step'] != $step && (empty($_POST['admin_login']) || empty($_POST['admin_password']) || ($_POST['admin_password'] != $_POST['admin_password_verif']))) { + header('location: config.php?err=1'); +} + +if($_SESSION['install']['step'] == 5) { + $admin = new \Thelia\Model\Admin(); + $admin->setLogin($_POST['admin_login']) + ->setPassword($_POST['admin_password']) + ->setFirstname('admin') + ->setLastname('admin') + ->save(); + + $config = new \Thelia\Model\Config(); + $config->setName('contact_email') + ->setValue($_POST['email_contact']) + ->save(); + ; +} + +$_SESSION['install']['step'] = $step; +?> + +
    +

    + Thank you have installed Thelia +

    +

    + Don't forget to delete the web/install directory. +

    + +
    + \ No newline at end of file diff --git a/web/install/fd33fd0-6fda040.ico b/web/install/fd33fd0-6fda040.ico new file mode 100755 index 000000000..24c27fefd Binary files /dev/null and b/web/install/fd33fd0-6fda040.ico differ diff --git a/web/install/footer.php b/web/install/footer.php new file mode 100755 index 000000000..29e87f2c2 --- /dev/null +++ b/web/install/footer.php @@ -0,0 +1,41 @@ +. */ +/* */ +/*************************************************************************************/ +?> +
  • +
    +
    + + +
    + + + + \ No newline at end of file diff --git a/web/install/header.php b/web/install/header.php new file mode 100755 index 000000000..983fa51ce --- /dev/null +++ b/web/install/header.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ +session_start(); +include 'bootstrap.php'; +?> + + + + Installation + + + + + +
    +
    +
    +
    +
    Version undefined
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Thelia installation wizard

    +
    +
      +
    • 1Welcome
    • +
    • 2Checking permissions
    • +
    • 3Database connection
    • +
    • 4Database selection
    • +
    • 5General information
    • +
    • 6Thanks
    • +
    +
    \ No newline at end of file diff --git a/web/install/index.php b/web/install/index.php new file mode 100755 index 000000000..884ca11b7 --- /dev/null +++ b/web/install/index.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ +?> + +
    +

    +Welcome in the Thelia installation wizard. +

    +

    +We will guide you throughout this process to install any application on your system. +

    +
    + + \ No newline at end of file diff --git a/web/install/permission.php b/web/install/permission.php new file mode 100755 index 000000000..fca995457 --- /dev/null +++ b/web/install/permission.php @@ -0,0 +1,56 @@ +. */ +/* */ +/*************************************************************************************/ +?> +getContainer()->get('thelia.translator')); +$isValid = $checkPermission->exec(); +$validationMessage = $checkPermission->getValidationMessages(); +$_SESSION['install']['return_step'] = 'permission.php'; +$_SESSION['install']['continue'] = $isValid; +$_SESSION['install']['current_step'] = 'permission.php'; +$_SESSION['install']['step'] = 2; +?> +
    +

    Checking permissions

    +
      + $data): ?> +
    • + + +
    • + +
    + +
    +
    + + Continue + + refresh + +
    + \ No newline at end of file diff --git a/web/install/script.js b/web/install/script.js new file mode 100755 index 000000000..b26e7612e --- /dev/null +++ b/web/install/script.js @@ -0,0 +1,1999 @@ +/** + * bootstrap.js v3.0.0 by @fat and @mdo + * Copyright 2013 Twitter Inc. + * http://www.apache.org/licenses/LICENSE-2.0 + */ +if (!jQuery) { throw new Error("Bootstrap requires jQuery") } + +/* ======================================================================== + * Bootstrap: transition.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#transitions + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) + // ============================================================ + + function transitionEnd() { + var el = document.createElement('bootstrap') + + var transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } + + for (var name in transEndEventNames) { + if (el.style[name] !== undefined) { + return { end: transEndEventNames[name] } + } + } + } + + // http://blog.alexmaccaw.com/css-transitions + $.fn.emulateTransitionEnd = function (duration) { + var called = false, $el = this + $(this).one($.support.transition.end, function () { called = true }) + var callback = function () { if (!called) $($el).trigger($.support.transition.end) } + setTimeout(callback, duration) + return this + } + + $(function () { + $.support.transition = transitionEnd() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: alert.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#alerts + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#buttons + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d); + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } + + this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: carousel.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#carousel + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.DEFAULTS = { + interval: 5000 + , pause: 'hover' + , wrap: true + } + + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) + + this.interval && clearInterval(this.interval) + + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + + return this + } + + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() + + return this.$items.index(this.$active) + } + + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() + + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } + + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } + + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } + + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } + + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + this.sliding = true + + isCycling && this.pause() + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + + if ($next.hasClass('active')) return + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + .emulateTransitionEnd(600) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + + // CAROUSEL PLUGIN DEFINITION + // ========================== + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } + + $.fn.carousel.Constructor = Carousel + + + // CAROUSEL NO CONFLICT + // ==================== + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + + // CAROUSEL DATA-API + // ================= + + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var $this = $(this), href + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false + + $target.carousel(options) + + if (slideIndex = $this.attr('data-slide-to')) { + $target.data('bs.carousel').to(slideIndex) + } + + e.preventDefault() + }) + + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + $carousel.carousel($carousel.data()) + }) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: collapse.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#collapse + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null + + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() + } + + Collapse.DEFAULTS = { + toggle: true + } + + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .panel > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) + } + + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) + + this.transitioning = 1 + + var complete = function () { + this.$element + .removeClass('collapsing') + .addClass('in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') + } + + if (!$.support.transition) return complete.call(this) + + var scrollSize = $.camelCase(['scroll', dimension].join('-')) + + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } + + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') + } + + if (!$.support.transition) return complete.call(this) + + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + + // COLLAPSE PLUGIN DEFINITION + // ========================== + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.Constructor = Collapse + + + // COLLAPSE NO CONFLICT + // ==================== + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + // COLLAPSE DATA-API + // ================= + + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + var $parent = parent && $(parent) + + if (!data || !data.transitioning) { + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + } + + $target.collapse(option) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we we use a backdrop because click events don't delegate + $('