Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-01-17 03:03:41 +0300
committerLukas Reschke <lukas@owncloud.com>2015-01-17 03:03:41 +0300
commit744cf713f7d6fff80f79465086a522f35d263ff5 (patch)
tree5b01004e362e86b79f33362b1931ee1b91634ed0 /lib/private/app.php
parent08d118eab794ee33c60dcb0fa13d1de495a12dfd (diff)
parent520d8ec53b672e768e59eaf0409559bbecc6c042 (diff)
Merge pull request #13319 from owncloud/replace-line-breaks-in-app-description
replace line breaks in the app description by spaces - fixes #13315
Diffstat (limited to 'lib/private/app.php')
-rw-r--r--lib/private/app.php39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index e75202eec23..3a1f731d621 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -642,6 +642,10 @@ class OC_App {
$parser = new \OC\App\InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator());
$data = $parser->parse($file);
+ if(is_array($data)) {
+ $data = OC_App::parseAppInfo($data);
+ }
+
self::$appInfo[$appId] = $data;
return $data;
@@ -914,7 +918,8 @@ class OC_App {
$i = 0;
$l = \OC::$server->getL10N('core');
foreach ($remoteApps as $app) {
- $app1[$i] = $app;
+ // enhance app info (for example the description)
+ $app1[$i] = OC_App::parseAppInfo($app);
$app1[$i]['author'] = $app['personid'];
$app1[$i]['ocs_id'] = $app['id'];
$app1[$i]['internal'] = $app1[$i]['active'] = 0;
@@ -1199,4 +1204,36 @@ class OC_App {
return false;
}
}
+
+ /**
+ * parses the app data array and enhanced the 'description' value
+ *
+ * @param array $data the app data
+ * @return array improved app data
+ */
+ public static function parseAppInfo(array $data) {
+
+ // just modify the description if it is available
+ // otherwise this will create a $data element with an empty 'description'
+ if(isset($data['description'])) {
+ // sometimes the description contains line breaks and they are then also
+ // shown in this way in the app management which isn't wanted as HTML
+ // manages line breaks itself
+
+ // first of all we split on empty lines
+ $paragraphs = preg_split("!\n[[:space:]]*\n!m", $data['description']);
+
+ $result = [];
+ foreach ($paragraphs as $value) {
+ // replace multiple whitespace (tabs, space, newlines) inside a paragraph
+ // with a single space - also trims whitespace
+ $result[] = trim(preg_replace('![[:space:]]+!m', ' ', $value));
+ }
+
+ // join the single paragraphs with a empty line in between
+ $data['description'] = implode("\n\n", $result);
+ }
+
+ return $data;
+ }
}