summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib
diff options
context:
space:
mode:
authorJulius Haertl <jus@bitgrid.net>2016-11-18 10:49:03 +0100
committerJulius Haertl <jus@bitgrid.net>2016-11-18 11:07:44 +0100
commit2ab4d1e0a3f15af2b8f04edcf18b7fe3fc0be262 (patch)
treeec035e8aec9d655e07bd06e4337a41c0bb8c4846 /apps/theming/lib
parentd409fe1c525ba05f342d52a9686ae395a0dac465 (diff)
downloadnextcloud-server-2ab4d1e0a3f15af2b8f04edcf18b7fe3fc0be262.tar.gz
nextcloud-server-2ab4d1e0a3f15af2b8f04edcf18b7fe3fc0be262.zip
Use IAppManager instead of OC_App
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/IconBuilder.php16
-rw-r--r--apps/theming/lib/Util.php73
2 files changed, 56 insertions, 33 deletions
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php
index be3035eb0d8..d8161051ebb 100644
--- a/apps/theming/lib/IconBuilder.php
+++ b/apps/theming/lib/IconBuilder.php
@@ -25,6 +25,7 @@ namespace OCA\Theming;
use Imagick;
use ImagickPixel;
+use OCP\App\AppPathNotFoundException;
class IconBuilder {
/** @var ThemingDefaults */
@@ -85,8 +86,13 @@ class IconBuilder {
* @return Imagick|false
*/
public function renderAppIcon($app) {
- $appIcon = $this->util->getAppIcon($app);
- $appIconContent = file_get_contents($appIcon);
+ try {
+ $appIcon = $this->util->getAppIcon($app);
+ $appIconContent = file_get_contents($appIcon);
+ } catch (AppPathNotFoundException $e) {
+ return false;
+ }
+
if($appIconContent === false) {
return false;
}
@@ -158,7 +164,11 @@ class IconBuilder {
}
public function colorSvg($app, $image) {
- $imageFile = $this->util->getAppImage($app, $image);
+ try {
+ $imageFile = $this->util->getAppImage($app, $image);
+ } catch (AppPathNotFoundException $e) {
+ return false;
+ }
$svg = file_get_contents($imageFile);
if ($svg !== false) {
$color = $this->util->elementColor($this->themingDefaults->getMailHeaderColor());
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index 963cf56633b..9fea56838ad 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -23,6 +23,8 @@
namespace OCA\Theming;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\Files\IRootFolder;
@@ -34,15 +36,20 @@ class Util {
/** @var IRootFolder */
private $rootFolder;
+ /** @var IAppManager */
+ private $appManager;
+
/**
* Util constructor.
*
* @param IConfig $config
* @param IRootFolder $rootFolder
+ * @param IAppManager $appManager
*/
- public function __construct(IConfig $config, IRootFolder $rootFolder) {
+ public function __construct(IConfig $config, IRootFolder $rootFolder, IAppManager $appManager) {
$this->config = $config;
$this->rootFolder = $rootFolder;
+ $this->appManager = $appManager;
}
/**
@@ -108,8 +115,8 @@ class Util {
*/
public function getAppIcon($app) {
$app = str_replace(array('\0', '/', '\\', '..'), '', $app);
- $appPath = \OC_App::getAppPath($app);
- if ($appPath !== false) {
+ try {
+ $appPath = $this->appManager->getAppPath($app);
$icon = $appPath . '/img/' . $app . '.svg';
if (file_exists($icon)) {
return $icon;
@@ -118,7 +125,8 @@ class Util {
if (file_exists($icon)) {
return $icon;
}
- }
+ } catch (AppPathNotFoundException $e) {}
+
if($this->config->getAppValue('theming', 'logoMime', '') !== '' && $this->rootFolder->nodeExists('/themedinstancelogo')) {
return $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedinstancelogo';
}
@@ -128,40 +136,45 @@ class Util {
/**
* @param $app string app name
* @param $image string relative path to image in app folder
- * @return string absolute path to image
+ * @return string|false absolute path to image
*/
public function getAppImage($app, $image) {
$app = str_replace(array('\0', '/', '\\', '..'), '', $app);
$image = str_replace(array('\0', '\\', '..'), '', $image);
- $appPath = \OC_App::getAppPath($app);
- if ($app === "core") {
- $icon = \OC::$SERVERROOT . '/core/img/' . $image;
- if (file_exists($icon)) {
- return $icon;
- }
- }
- if ($appPath !== false) {
- $icon = $appPath . '/img/' . $image;
- if (file_exists($icon)) {
- return $icon;
- }
- $icon = $appPath . '/img/' . $image . '.svg';
- if (file_exists($icon)) {
- return $icon;
- }
- $icon = $appPath . '/img/' . $image . '.png';
- if (file_exists($icon)) {
- return $icon;
- }
- $icon = $appPath . '/img/' . $image . '.gif';
- if (file_exists($icon)) {
- return $icon;
- }
- $icon = $appPath . '/img/' . $image . '.jpg';
+ if ($app === "core") {
+ $icon = \OC::$SERVERROOT . '/core/img/' . $image;
if (file_exists($icon)) {
return $icon;
}
}
+
+ try {
+ $appPath = $this->appManager->getAppPath($app);
+ } catch (AppPathNotFoundException $e) {
+ return false;
+ }
+
+ $icon = $appPath . '/img/' . $image;
+ if (file_exists($icon)) {
+ return $icon;
+ }
+ $icon = $appPath . '/img/' . $image . '.svg';
+ if (file_exists($icon)) {
+ return $icon;
+ }
+ $icon = $appPath . '/img/' . $image . '.png';
+ if (file_exists($icon)) {
+ return $icon;
+ }
+ $icon = $appPath . '/img/' . $image . '.gif';
+ if (file_exists($icon)) {
+ return $icon;
+ }
+ $icon = $appPath . '/img/' . $image . '.jpg';
+ if (file_exists($icon)) {
+ return $icon;
+ }
+
return false;
}