- Added parameter blockTags to controller Phrase

If this parameter is set to "no", it will be removed the tags <p> and </p>
from the beginning and from the end of the returned phrases
This commit is contained in:
paolo
2016-07-29 15:36:32 +02:00
parent fd826ae1fe
commit 4b82843c76
3 changed files with 17 additions and 4 deletions
@@ -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);
}
+14 -2
View File
@@ -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 <p> tags required
if ($blockTags == "no")
{
// Removes tags <p> and </p> 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);
}
}
}
}
+1 -1
View File
@@ -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":
{