From a552eead99ab172dc044ab198f4ed246df950116 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 21 Feb 2014 10:13:38 +0100 Subject: [PATCH 1/6] fix loop cache system. type argument is now a default argument. Fix #234 --- core/lib/Thelia/Core/Template/Element/BaseLoop.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index de851cc8c..ad92cefbe 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -95,6 +95,7 @@ abstract class BaseLoop $defaultArgs = array( Argument::createBooleanTypeArgument('backend_context', false), Argument::createBooleanTypeArgument('force_return', false), + Argument::createAnyTypeArgument('type', null, true), ); if (true === $this->countable) { From 67e689ff850f9e257fe6dfe4b60eb5956288ded5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Espeche?= Date: Wed, 25 Jun 2014 15:25:32 +0200 Subject: [PATCH 2/6] Reinit file --- core/lib/Thelia/Core/Template/Element/BaseLoop.php | 1 - 1 file changed, 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index e08d13dd6..d120b1c41 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -535,5 +535,4 @@ abstract class BaseLoop * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection */ abstract protected function getArgDefinitions(); - } \ No newline at end of file From 079f627de9eb3034c699041f5af3f84867cd85dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Espeche?= Date: Wed, 25 Jun 2014 15:25:56 +0200 Subject: [PATCH 3/6] Reinit file --- core/lib/Thelia/Core/Template/Element/BaseLoop.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index d120b1c41..929b7f455 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -535,4 +535,6 @@ abstract class BaseLoop * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection */ abstract protected function getArgDefinitions(); + + } \ No newline at end of file From d7a55257d546d1d61e2203f6d98961b4d5d9eb91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Espeche?= Date: Wed, 25 Jun 2014 15:29:28 +0200 Subject: [PATCH 4/6] Reinit file --- core/lib/Thelia/Core/Template/Element/BaseLoop.php | 1 - 1 file changed, 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 929b7f455..e08d13dd6 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -536,5 +536,4 @@ abstract class BaseLoop */ abstract protected function getArgDefinitions(); - } \ No newline at end of file From ed464db6fdb9a5632e26a5b0d72166db0d33b472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Espeche?= Date: Wed, 25 Jun 2014 16:43:06 +0200 Subject: [PATCH 5/6] Add substitution --- .../Thelia/Core/Template/Loop/Category.php | 1 + core/lib/Thelia/Core/Template/Loop/Folder.php | 1 + core/lib/Thelia/Model/Category.php | 22 +++++++++++++++++++ core/lib/Thelia/Model/Folder.php | 22 +++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 9ecee9182..e416aa9a1 100644 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -214,6 +214,7 @@ class Category extends BaseI18nLoop implements PropelSearchLoopInterface, Search ->set("DESCRIPTION" , $category->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM" , $category->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT" , $category->getParent()) + ->set("ROOT" , $category->getRoot($category->getId())) ->set("URL" , $category->getUrl($this->locale)) ->set("META_TITLE" , $category->getVirtualColumn('i18n_META_TITLE')) ->set("META_DESCRIPTION" , $category->getVirtualColumn('i18n_META_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index ee4e0cbbe..73719a775 100644 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -175,6 +175,7 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLo ->set("DESCRIPTION" , $folder->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM" , $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT" , $folder->getParent()) + ->set("ROOT" , $folder->getRoot($folder->getId())) ->set("URL" , $folder->getUrl($this->locale)) ->set("META_TITLE" , $folder->getVirtualColumn('i18n_META_TITLE')) ->set("META_DESCRIPTION" , $folder->getVirtualColumn('i18n_META_DESCRIPTION')) diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index c5ab471a5..1b4582fd0 100644 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -56,6 +56,28 @@ class Category extends BaseCategory return $countProduct; } + /** + * Get the root category + * @param int $categoryId + * @return mixed + */ + public function getRoot($categoryId) + { + + $category = CategoryQuery::create()->findOneById($categoryId); + + if(0 !== $category->getParent()) { + $parentCategory = CategoryQuery::create()->findOneById($category->getParent()); + + if (null !== $parentCategory) { + $categoryId = $this->getRoot($parentCategory->getId()); + } + } + + return $categoryId; + + } + /** * Calculate next position relative to our parent */ diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index e8bc43498..c016aefe2 100644 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -55,6 +55,28 @@ class Folder extends BaseFolder } + /** + * Get the root folder + * @param int $folderId + * @return mixed + */ + public function getRoot($folderId) + { + + $folder = FolderQuery::create()->findOneById($folderId); + + if(0 !== $folder->getParent()) { + $parentFolder = FolderQuery::create()->findOneById($folder->getParent()); + + if (null !== $parentFolder) { + $folderId = $this->getRoot($parentFolder->getId()); + } + } + + return $folderId; + + } + /** * Calculate next position relative to our parent */ From 6661341eb4f29428c19fa575f17052a8e26b02a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Espeche?= Date: Thu, 26 Jun 2014 08:59:21 +0200 Subject: [PATCH 6/6] Replace findOneById by findPk --- core/lib/Thelia/Model/Category.php | 4 ++-- core/lib/Thelia/Model/Folder.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 1b4582fd0..e5c9708db 100644 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -64,10 +64,10 @@ class Category extends BaseCategory public function getRoot($categoryId) { - $category = CategoryQuery::create()->findOneById($categoryId); + $category = CategoryQuery::create()->findPk($categoryId); if(0 !== $category->getParent()) { - $parentCategory = CategoryQuery::create()->findOneById($category->getParent()); + $parentCategory = CategoryQuery::create()->findPk($category->getParent()); if (null !== $parentCategory) { $categoryId = $this->getRoot($parentCategory->getId()); diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index c016aefe2..31ba041c4 100644 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -63,10 +63,10 @@ class Folder extends BaseFolder public function getRoot($folderId) { - $folder = FolderQuery::create()->findOneById($folderId); + $folder = FolderQuery::create()->findPk($folderId); if(0 !== $folder->getParent()) { - $parentFolder = FolderQuery::create()->findOneById($folder->getParent()); + $parentFolder = FolderQuery::create()->findPk($folder->getParent()); if (null !== $parentFolder) { $folderId = $this->getRoot($parentFolder->getId());