From 50212c55cf50a55f702b863fec3d5cac3fb83f59 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 17 Sep 2013 17:50:05 +0200 Subject: [PATCH] remove old model classes: --- core/lib/Thelia/Model/Rewriting.php | 9 -------- core/lib/Thelia/Model/RewritingQuery.php | 20 ---------------- .../Thelia/Model/Tools/UrlRewritingTrait.php | 23 ++++++++++++++++++- 3 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 core/lib/Thelia/Model/Rewriting.php delete mode 100644 core/lib/Thelia/Model/RewritingQuery.php 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 @@ -generateRewritenUrl($this->getRewritenUrlViewName(), $this->getId(), $locale, $this->getTitle()); + // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe + + $this->setLocale($locale); + // Replace all weird characters with dashes + $string = preg_replace('/[^\w\-~_\.]+/u', '-', $this->getTitle()); + + // 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 + try{ + URL::getInstance()->resolve($urlFilePart); + } catch (UrlRewritingException $e) { + + } + // insert the URL in the rewriting table + //URL::getInstance()->generateRewritenUrl($this->getRewritenUrlViewName(), $this->getId(), $locale, $this->getTitle()); } /**