Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
3a5022ad
Unverified
Commit
3a5022ad
authored
8 years ago
by
Joas Schilling
Browse files
Options
Downloads
Patches
Plain Diff
Allow multiple names and description
Signed-off-by:
Joas Schilling
<
coding@schilljs.com
>
parent
99076a8c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/legacy/app.php
+40
-7
40 additions, 7 deletions
lib/private/legacy/app.php
with
40 additions
and
7 deletions
lib/private/legacy/app.php
+
40
−
7
View file @
3a5022ad
...
...
@@ -662,15 +662,16 @@ class OC_App {
* Read all app metadata from the info.xml file
*
* @param string $appId id of the app or the path of the info.xml file
* @param boolean $path (optional)
* @param bool $path
* @param string $lang
* @return array|null
* @note all data is read from info.xml, not just pre-defined fields
*/
public
static
function
getAppInfo
(
$appId
,
$path
=
false
)
{
public
static
function
getAppInfo
(
$appId
,
$path
=
false
,
$lang
=
null
)
{
if
(
$path
)
{
$file
=
$appId
;
}
else
{
if
(
isset
(
self
::
$appInfo
[
$appId
]))
{
if
(
$lang
===
null
&&
isset
(
self
::
$appInfo
[
$appId
]))
{
return
self
::
$appInfo
[
$appId
];
}
$appPath
=
self
::
getAppPath
(
$appId
);
...
...
@@ -684,7 +685,7 @@ class OC_App {
$data
=
$parser
->
parse
(
$file
);
if
(
is_array
(
$data
))
{
$data
=
OC_App
::
parseAppInfo
(
$data
);
$data
=
OC_App
::
parseAppInfo
(
$data
,
$lang
);
}
if
(
isset
(
$data
[
'ocsid'
]))
{
$storedId
=
\OC
::
$server
->
getConfig
()
->
getAppValue
(
$appId
,
'ocsid'
);
...
...
@@ -693,7 +694,9 @@ class OC_App {
}
}
self
::
$appInfo
[
$appId
]
=
$data
;
if
(
$lang
===
null
)
{
self
::
$appInfo
[
$appId
]
=
$data
;
}
return
$data
;
}
...
...
@@ -843,11 +846,12 @@ class OC_App {
//we don't want to show configuration for these
$blacklist
=
\OC
::
$server
->
getAppManager
()
->
getAlwaysEnabledApps
();
$appList
=
array
();
$langCode
=
\OC
::
$server
->
getL10N
(
'core'
)
->
getLanguageCode
();
foreach
(
$installedApps
as
$app
)
{
if
(
array_search
(
$app
,
$blacklist
)
===
false
)
{
$info
=
OC_App
::
getAppInfo
(
$app
);
$info
=
OC_App
::
getAppInfo
(
$app
,
false
,
$langCode
);
if
(
!
is_array
(
$info
))
{
\OCP\Util
::
writeLog
(
'core'
,
'Could not read app info file for app "'
.
$app
.
'"'
,
\OCP\Util
::
ERROR
);
continue
;
...
...
@@ -1327,13 +1331,42 @@ class OC_App {
}
}
protected
static
function
findBestL10NOption
(
$options
,
$lang
)
{
$fallback
=
$englishFallback
=
false
;
foreach
(
$options
as
$option
)
{
if
(
is_array
(
$option
))
{
if
(
$fallback
===
false
)
{
$fallback
=
$option
[
'@value'
];
}
if
(
isset
(
$option
[
'@attributes'
][
'lang'
])
&&
$option
[
'@attributes'
][
'lang'
]
===
$lang
)
{
return
$option
[
'@value'
];
}
}
else
{
$englishFallback
=
$option
;
}
}
return
$englishFallback
!==
false
?
$englishFallback
:
(
string
)
$fallback
;
}
/**
* parses the app data array and enhanced the 'description' value
*
* @param array $data the app data
* @param string $lang
* @return array improved app data
*/
public
static
function
parseAppInfo
(
array
$data
)
{
public
static
function
parseAppInfo
(
array
$data
,
$lang
=
null
)
{
if
(
$lang
&&
isset
(
$data
[
'name'
])
&&
is_array
(
$data
[
'name'
]))
{
$data
[
'name'
]
=
self
::
findBestL10NOption
(
$data
[
'name'
],
$lang
);
}
if
(
$lang
&&
isset
(
$data
[
'summary'
])
&&
is_array
(
$data
[
'summary'
]))
{
$data
[
'summary'
]
=
self
::
findBestL10NOption
(
$data
[
'summary'
],
$lang
);
}
if
(
$lang
&&
isset
(
$data
[
'description'
])
&&
is_array
(
$data
[
'description'
]))
{
$data
[
'description'
]
=
self
::
findBestL10NOption
(
$data
[
'description'
],
$lang
);
}
// just modify the description if it is available
// otherwise this will create a $data element with an empty 'description'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment