partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 836e9e24fa7da42312fd37b0249ec088f61f97c3
parent 78f8dcc3d68a4cb1e3999ff38d129acdb1b0c0b0
Author: Felicitus <felicitus@felicitus.org>
Date:   Sun, 25 Mar 2012 03:21:33 +0200

Don't bail out for unset category paths; changed hard-coded path separator to a configuration option.

Diffstat:
Mconfig.php.template | 7+++++++
Ascripts/UpdateCategoryPathCache.php | 26++++++++++++++++++++++++++
Msrc/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategory.php | 2+-
Msrc/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryManager.php | 13++++++++-----
4 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/config.php.template b/config.php.template @@ -121,3 +121,10 @@ Configuration::setOption("partkeepr.cronjobs.disablecheck", false); * Specifies if password changing is allowed. */ Configuration::setOption("partkeepr.frontend.allow_password_change", true); + +/** + * Specifies the separator for category paths. If you change this, you need to rebuild the category paths by + * executing the script scripts/UpdateCategoryPathCache.php + * + */ +Configuration::setOption("partkeepr.category.path_separator", " ➤ "); diff --git a/scripts/UpdateCategoryPathCache.php b/scripts/UpdateCategoryPathCache.php @@ -0,0 +1,25 @@ +<?php +/** + * This is a script which updates all category path caches to the configured path separator. + * + * This script needs to be called after changing the partkeepr.category.path_separator. + */ +namespace de\RaumZeitLabor\PartKeepr\Scripts; + +use de\RaumZeitLabor\PartKeepr\PartKeepr, + de\RaumZeitLabor\PartKeepr\PartCategory\PartCategoryManager, + de\RaumZeitLabor\PartKeepr\Util\Configuration, + de\RaumZeitLabor\PartKeepr\FootprintCategory\FootprintCategoryManager; + +include("../src/backend/de/RaumZeitLabor/PartKeepr/PartKeepr.php"); + + +PartKeepr::initialize(); + +PartCategoryManager::getInstance()->updateCategoryPaths(PartCategoryManager::getInstance()->getRootNode()); +FootprintCategoryManager::getInstance()->updateCategoryPaths(FootprintCategoryManager::getInstance()->getRootNode()); + +PartKeepr::getEM()->flush(); + +echo "All categories are updated for the configured category seperator of "; +echo Configuration::getOption("partkeepr.category.path_separator") ."\n";+ \ No newline at end of file diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategory.php b/src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategory.php @@ -51,7 +51,7 @@ class AbstractCategory extends BaseEntity implements Node, Serializable { /** * Holds the category path. * - * @Column(type="text") + * @Column(type="text",nullable=true) * * @var string */ diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryManager.php b/src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryManager.php @@ -5,10 +5,11 @@ use de\RaumZeitLabor\PartKeepr\Util\Singleton, de\RaumZeitLabor\PartKeepr\Category\Category, de\RaumZeitLabor\PartKeepr\Util\SerializableException, de\RaumZeitLabor\PartKeepr\Category\Exceptions\CategoryNotFoundException, - de\RaumZeitLabor\PartKeepr\PartKeepr; -use DoctrineExtensions\NestedSet\Manager; -use DoctrineExtensions\NestedSet\Config; -use DoctrineExtensions\NestedSet\NodeWrapper; + de\RaumZeitLabor\PartKeepr\PartKeepr, + de\RaumZeitLabor\PartKeepr\Util\Configuration, + DoctrineExtensions\NestedSet\Manager, + DoctrineExtensions\NestedSet\Config, + DoctrineExtensions\NestedSet\NodeWrapper; abstract class AbstractCategoryManager extends Singleton { /** @@ -158,7 +159,9 @@ abstract class AbstractCategoryManager extends Singleton { * @param NodeWrapper $startNode The node to start updating at */ public function updateCategoryPaths (NodeWrapper $startNode) { - $startNode->getNode()->setCategoryPath($startNode->getPath(" ➤ ", true)); + $pathSeparator = Configuration::getOption("partkeepr.category.path_separator", " ➤ "); + + $startNode->getNode()->setCategoryPath($startNode->getPath($pathSeparator, true)); foreach ($startNode->getChildren() as $child) { $this->updateCategoryPaths($child);