From 4b82843c76766a083e54a1f25c94770761faeaa8 Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 29 Jul 2016 15:36:32 +0200 Subject: [PATCH] - Added parameter blockTags to controller Phrase If this parameter is set to "no", it will be removed the tags

and

from the beginning and from the end of the returned phrases --- application/controllers/api/v1/system/Phrase.php | 3 ++- application/libraries/PhrasesLib.php | 16 ++++++++++++++-- composer.json | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/application/controllers/api/v1/system/Phrase.php b/application/controllers/api/v1/system/Phrase.php index 7821d42f4..31decf540 100644 --- a/application/controllers/api/v1/system/Phrase.php +++ b/application/controllers/api/v1/system/Phrase.php @@ -54,10 +54,11 @@ class Phrase extends APIv1_Controller $phrase = $this->get('phrase'); $orgeinheit_kurzbz = $this->get('orgeinheit_kurzbz'); $orgform_kurzbz = $this->get('orgform_kurzbz'); + $blockTags = $this->get('blockTags'); if (isset($app) && isset($sprache)) { - $result = $this->phraseslib->getPhrases($app, $sprache, $phrase, $orgeinheit_kurzbz, $orgform_kurzbz); + $result = $this->phraseslib->getPhrases($app, $sprache, $phrase, $orgeinheit_kurzbz, $orgform_kurzbz, $blockTags); $this->response($result, REST_Controller::HTTP_OK); } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index 5a1ca48f8..d4fa939e6 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -111,7 +111,7 @@ class PhrasesLib * * @return struct */ - function getPhrases($app, $sprache, $phrase = null, $orgeinheit_kurzbz = null, $orgform_kurzbz = null) + function getPhrases($app, $sprache, $phrase = null, $orgeinheit_kurzbz = null, $orgform_kurzbz = null, $blockTags = null) { if (isset($app) && isset($sprache)) { @@ -123,7 +123,19 @@ class PhrasesLib for ($i = 0; $i < count($result->retval); $i++) { - $result->retval[$i]->text = $parser->textileThis($result->retval[$i]->text); + // If no

tags required + if ($blockTags == "no") + { + // Removes tags

and

from the beginning and from the end of the string + $tmpText = $parser->textileThis($result->retval[$i]->text); + $tmpText = substr($tmpText, 3, strlen($tmpText)); + $tmpText = substr($tmpText, 0, strlen($tmpText) - 4); + $result->retval[$i]->text = $tmpText; + } + else + { + $result->retval[$i]->text = $parser->textileThis($result->retval[$i]->text); + } } } } diff --git a/composer.json b/composer.json index 3b1f37eb5..d8469d498 100755 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ "json-forms": "1.4.0", "wikimedia/composer-merge-plugin": "^1.3", "fzaninotto/faker": "1.*", - "netcarver/textile": "3.5.*" + "netcarver/textile": "^3.5" }, "require-dev": {