From 44b85932445d3da054329f7955ee3e8bd4233fce Mon Sep 17 00:00:00 2001 From: NourAlmasrieh <71821036+NourAlmasrieh@users.noreply.github.com> Date: Tue, 16 Mar 2021 11:01:22 +0100 Subject: [PATCH 1/3] 0.2.1 --- src/DataObjects/JobCategory.php | 35 ++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/DataObjects/JobCategory.php b/src/DataObjects/JobCategory.php index 1ed4d31..89cf416 100644 --- a/src/DataObjects/JobCategory.php +++ b/src/DataObjects/JobCategory.php @@ -68,9 +68,34 @@ public function getCMSFields() * Event handler called before writing to the database. */ public function onBeforeWrite() - { - parent::onBeforeWrite(); - $this->TagSortTitle = $this->Title; - $this->extend("updateOnBeforeWrite"); - } + { + parent::onBeforeWrite(); + if($this->URLSegment == "") + { + $this->URLSegment = $this->constructURLSegment(); + } + $this->TagSortTitle = $this->Title; + $this->extend("updateOnBeforeWrite"); + } + + private function constructURLSegment() + { + return $this->cleanLink(strtolower(str_replace(" ", "-", $this->Title))); + } + + private function cleanLink($string) + { + $string = str_replace("ä", "ae", $string); + $string = str_replace("ü", "ue", $string); + $string = str_replace("ö", "oe", $string); + $string = str_replace("Ä", "Ae", $string); + $string = str_replace("Ü", "Ue", $string); + $string = str_replace("Ö", "Oe", $string); + $string = str_replace("ß", "ss", $string); + $string = str_replace(["´", ",", ":", ";"], "", $string); + $string = str_replace(["´", ",", ":", ";"], "", $string); + $string = str_replace(["/", "(", ")"], "_", $string); + $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); + return $string; + } } From f6d7601c693fc7bfcccc46d1c500047ca7744b29 Mon Sep 17 00:00:00 2001 From: chromos33 Date: Wed, 23 Jun 2021 14:29:17 +0200 Subject: [PATCH 2/3] Update JobsPage.php --- src/Pages/JobsPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pages/JobsPage.php b/src/Pages/JobsPage.php index cfd7d27..7f596ce 100644 --- a/src/Pages/JobsPage.php +++ b/src/Pages/JobsPage.php @@ -108,7 +108,7 @@ public function getCMSFields() ) ); } - $this->extend('updateCMSFields', $fields); + $this->extend('updateJobPageCMSFields', $fields); return $fields; } } From a5b5f0fafc6c09fb6fa8f172b2c55026e8760736 Mon Sep 17 00:00:00 2001 From: chromos33 Date: Wed, 23 Jun 2021 14:31:13 +0200 Subject: [PATCH 3/3] Update JobCategory.php --- src/DataObjects/JobCategory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataObjects/JobCategory.php b/src/DataObjects/JobCategory.php index 89cf416..3506521 100644 --- a/src/DataObjects/JobCategory.php +++ b/src/DataObjects/JobCategory.php @@ -37,7 +37,8 @@ public function Link(){ private static $db = [ 'Title' => 'Text', 'TagSortTitle' => 'Text', - 'Sort' => 'Int' + 'Sort' => 'Int', + 'URLSegment' => 'Varchar(255)' ]; /** * CMS Fields