Passed
Push — master ( 4987fe...db5ac9 )
by John
13:30 queued 12s
created
lib/public/Search/IProvider.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -39,56 +39,56 @@
 block discarded – undo
39 39
  */
40 40
 interface IProvider {
41 41
 
42
-	/**
43
-	 * Get the unique ID of this search provider
44
-	 *
45
-	 * Ideally this should be the app name or an identifier identified with the
46
-	 * app name, especially if the app registers more than one provider.
47
-	 *
48
-	 * Example: 'mail', 'mail_recipients', 'files_sharing'
49
-	 *
50
-	 * @return string
51
-	 *
52
-	 * @since 20.0.0
53
-	 */
54
-	public function getId(): string;
42
+    /**
43
+     * Get the unique ID of this search provider
44
+     *
45
+     * Ideally this should be the app name or an identifier identified with the
46
+     * app name, especially if the app registers more than one provider.
47
+     *
48
+     * Example: 'mail', 'mail_recipients', 'files_sharing'
49
+     *
50
+     * @return string
51
+     *
52
+     * @since 20.0.0
53
+     */
54
+    public function getId(): string;
55 55
 
56
-	/**
57
-	 * Get the translated name of this search provider
58
-	 *
59
-	 * Example: 'Mail', 'Contacts'...
60
-	 *
61
-	 * @return string
62
-	 *
63
-	 * @since 20.0.0
64
-	 */
65
-	public function getName(): string;
56
+    /**
57
+     * Get the translated name of this search provider
58
+     *
59
+     * Example: 'Mail', 'Contacts'...
60
+     *
61
+     * @return string
62
+     *
63
+     * @since 20.0.0
64
+     */
65
+    public function getName(): string;
66 66
 
67
-	/**
68
-	 * Find matching search entries in an app
69
-	 *
70
-	 * Search results can either be a complete list of all the matches the app can
71
-	 * find, or ideally a paginated result set where more data can be fetched on
72
-	 * demand. To be able to tell where the next offset starts the search uses
73
-	 * "cursors" which are a property of the last result entry. E.g. search results
74
-	 * that show most recent entries first can look for entries older than the last
75
-	 * one of the first result set. This approach was chosen over a numeric limit/
76
-	 * offset approach as the offset moves as new data comes in. The cursor is
77
-	 * resistant to these changes and will still show results without overlaps or
78
-	 * gaps.
79
-	 *
80
-	 * See https://dev.to/jackmarchant/offset-and-cursor-pagination-explained-b89
81
-	 * for the concept of cursors.
82
-	 *
83
-	 * Implementations that return result pages have to adhere to the limit
84
-	 * property of a search query.
85
-	 *
86
-	 * @param IUser $user
87
-	 * @param ISearchQuery $query
88
-	 *
89
-	 * @return SearchResult
90
-	 *
91
-	 * @since 20.0.0
92
-	 */
93
-	public function search(IUser $user, ISearchQuery $query): SearchResult;
67
+    /**
68
+     * Find matching search entries in an app
69
+     *
70
+     * Search results can either be a complete list of all the matches the app can
71
+     * find, or ideally a paginated result set where more data can be fetched on
72
+     * demand. To be able to tell where the next offset starts the search uses
73
+     * "cursors" which are a property of the last result entry. E.g. search results
74
+     * that show most recent entries first can look for entries older than the last
75
+     * one of the first result set. This approach was chosen over a numeric limit/
76
+     * offset approach as the offset moves as new data comes in. The cursor is
77
+     * resistant to these changes and will still show results without overlaps or
78
+     * gaps.
79
+     *
80
+     * See https://dev.to/jackmarchant/offset-and-cursor-pagination-explained-b89
81
+     * for the concept of cursors.
82
+     *
83
+     * Implementations that return result pages have to adhere to the limit
84
+     * property of a search query.
85
+     *
86
+     * @param IUser $user
87
+     * @param ISearchQuery $query
88
+     *
89
+     * @return SearchResult
90
+     *
91
+     * @since 20.0.0
92
+     */
93
+    public function search(IUser $user, ISearchQuery $query): SearchResult;
94 94
 }
Please login to merge, or discard this patch.
lib/public/Search/ASearchResultEntry.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -44,79 +44,79 @@
 block discarded – undo
44 44
  */
45 45
 abstract class ASearchResultEntry implements JsonSerializable {
46 46
 
47
-	/**
48
-	 * @var string
49
-	 * @since 20.0.0
50
-	 */
51
-	protected $thumbnailUrl;
47
+    /**
48
+     * @var string
49
+     * @since 20.0.0
50
+     */
51
+    protected $thumbnailUrl;
52 52
 
53
-	/**
54
-	 * @var string
55
-	 * @since 20.0.0
56
-	 */
57
-	protected $title;
53
+    /**
54
+     * @var string
55
+     * @since 20.0.0
56
+     */
57
+    protected $title;
58 58
 
59
-	/**
60
-	 * @var string
61
-	 * @since 20.0.0
62
-	 */
63
-	protected $subline;
59
+    /**
60
+     * @var string
61
+     * @since 20.0.0
62
+     */
63
+    protected $subline;
64 64
 
65
-	/**
66
-	 * @var string
67
-	 * @since 20.0.0
68
-	 */
69
-	protected $resourceUrl;
65
+    /**
66
+     * @var string
67
+     * @since 20.0.0
68
+     */
69
+    protected $resourceUrl;
70 70
 
71
-	/**
72
-	 * @var string
73
-	 * @since 20.0.0
74
-	 */
75
-	protected $iconClass;
71
+    /**
72
+     * @var string
73
+     * @since 20.0.0
74
+     */
75
+    protected $iconClass;
76 76
 
77
-	/**
78
-	 * @var boolean
79
-	 * @since 20.0.0
80
-	 */
81
-	protected $rounded;
77
+    /**
78
+     * @var boolean
79
+     * @since 20.0.0
80
+     */
81
+    protected $rounded;
82 82
 
83
-	/**
84
-	 * @param string $thumbnailUrl a relative or absolute URL to the thumbnail or icon of the entry
85
-	 * @param string $title a main title of the entry
86
-	 * @param string $subline the secondary line of the entry
87
-	 * @param string $resourceUrl the URL where the user can find the detail, like a deep link inside the app
88
-	 * @param string $iconClass the icon class fallback
89
-	 * @param boolean $rounded is the thumbnail rounded
90
-	 *
91
-	 * @since 20.0.0
92
-	 */
93
-	public function __construct(string $thumbnailUrl,
94
-								string $title,
95
-								string $subline,
96
-								string $resourceUrl,
97
-								string $iconClass = '',
98
-								bool $rounded = false) {
99
-		$this->thumbnailUrl = $thumbnailUrl;
100
-		$this->title = $title;
101
-		$this->subline = $subline;
102
-		$this->resourceUrl = $resourceUrl;
103
-		$this->iconClass = $iconClass;
104
-		$this->rounded = $rounded;
105
-	}
83
+    /**
84
+     * @param string $thumbnailUrl a relative or absolute URL to the thumbnail or icon of the entry
85
+     * @param string $title a main title of the entry
86
+     * @param string $subline the secondary line of the entry
87
+     * @param string $resourceUrl the URL where the user can find the detail, like a deep link inside the app
88
+     * @param string $iconClass the icon class fallback
89
+     * @param boolean $rounded is the thumbnail rounded
90
+     *
91
+     * @since 20.0.0
92
+     */
93
+    public function __construct(string $thumbnailUrl,
94
+                                string $title,
95
+                                string $subline,
96
+                                string $resourceUrl,
97
+                                string $iconClass = '',
98
+                                bool $rounded = false) {
99
+        $this->thumbnailUrl = $thumbnailUrl;
100
+        $this->title = $title;
101
+        $this->subline = $subline;
102
+        $this->resourceUrl = $resourceUrl;
103
+        $this->iconClass = $iconClass;
104
+        $this->rounded = $rounded;
105
+    }
106 106
 
107
-	/**
108
-	 * @return array
109
-	 *
110
-	 * @since 20.0.0
111
-	 */
112
-	public function jsonSerialize(): array {
113
-		return [
114
-			'thumbnailUrl' => $this->thumbnailUrl,
115
-			'title' => $this->title,
116
-			'subline' => $this->subline,
117
-			'resourceUrl' => $this->resourceUrl,
118
-			'iconClass' => $this->iconClass,
119
-			'rounded' => $this->rounded,
120
-		];
121
-	}
107
+    /**
108
+     * @return array
109
+     *
110
+     * @since 20.0.0
111
+     */
112
+    public function jsonSerialize(): array {
113
+        return [
114
+            'thumbnailUrl' => $this->thumbnailUrl,
115
+            'title' => $this->title,
116
+            'subline' => $this->subline,
117
+            'resourceUrl' => $this->resourceUrl,
118
+            'iconClass' => $this->iconClass,
119
+            'rounded' => $this->rounded,
120
+        ];
121
+    }
122 122
 }
Please login to merge, or discard this patch.
lib/private/Search/SearchQuery.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -28,61 +28,61 @@
 block discarded – undo
28 28
 use OCP\Search\ISearchQuery;
29 29
 
30 30
 class SearchQuery implements ISearchQuery {
31
-	public const LIMIT_DEFAULT = 5;
31
+    public const LIMIT_DEFAULT = 5;
32 32
 
33
-	/** @var string */
34
-	private $term;
33
+    /** @var string */
34
+    private $term;
35 35
 
36
-	/** @var int */
37
-	private $sortOrder;
36
+    /** @var int */
37
+    private $sortOrder;
38 38
 
39
-	/** @var int */
40
-	private $limit;
39
+    /** @var int */
40
+    private $limit;
41 41
 
42
-	/** @var int|string|null */
43
-	private $cursor;
42
+    /** @var int|string|null */
43
+    private $cursor;
44 44
 
45
-	/**
46
-	 * @param string $term
47
-	 * @param int $sortOrder
48
-	 * @param int $limit
49
-	 * @param int|string|null $cursor
50
-	 */
51
-	public function __construct(string $term,
52
-								int $sortOrder = ISearchQuery::SORT_DATE_DESC,
53
-								int $limit = self::LIMIT_DEFAULT,
54
-								$cursor = null) {
55
-		$this->term = $term;
56
-		$this->sortOrder = $sortOrder;
57
-		$this->limit = $limit;
58
-		$this->cursor = $cursor;
59
-	}
45
+    /**
46
+     * @param string $term
47
+     * @param int $sortOrder
48
+     * @param int $limit
49
+     * @param int|string|null $cursor
50
+     */
51
+    public function __construct(string $term,
52
+                                int $sortOrder = ISearchQuery::SORT_DATE_DESC,
53
+                                int $limit = self::LIMIT_DEFAULT,
54
+                                $cursor = null) {
55
+        $this->term = $term;
56
+        $this->sortOrder = $sortOrder;
57
+        $this->limit = $limit;
58
+        $this->cursor = $cursor;
59
+    }
60 60
 
61
-	/**
62
-	 * @inheritDoc
63
-	 */
64
-	public function getTerm(): string {
65
-		return $this->term;
66
-	}
61
+    /**
62
+     * @inheritDoc
63
+     */
64
+    public function getTerm(): string {
65
+        return $this->term;
66
+    }
67 67
 
68
-	/**
69
-	 * @inheritDoc
70
-	 */
71
-	public function getSortOrder(): int {
72
-		return $this->sortOrder;
73
-	}
68
+    /**
69
+     * @inheritDoc
70
+     */
71
+    public function getSortOrder(): int {
72
+        return $this->sortOrder;
73
+    }
74 74
 
75
-	/**
76
-	 * @inheritDoc
77
-	 */
78
-	public function getLimit(): int {
79
-		return $this->limit;
80
-	}
75
+    /**
76
+     * @inheritDoc
77
+     */
78
+    public function getLimit(): int {
79
+        return $this->limit;
80
+    }
81 81
 
82
-	/**
83
-	 * @inheritDoc
84
-	 */
85
-	public function getCursor() {
86
-		return $this->cursor;
87
-	}
82
+    /**
83
+     * @inheritDoc
84
+     */
85
+    public function getCursor() {
86
+        return $this->cursor;
87
+    }
88 88
 }
Please login to merge, or discard this patch.
lib/private/Search/SearchComposer.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -57,93 +57,93 @@
 block discarded – undo
57 57
  */
58 58
 class SearchComposer {
59 59
 
60
-	/** @var IProvider[] */
61
-	private $providers = [];
62
-
63
-	/** @var Coordinator */
64
-	private $bootstrapCoordinator;
65
-
66
-	/** @var IServerContainer */
67
-	private $container;
68
-
69
-	/** @var ILogger */
70
-	private $logger;
71
-
72
-	public function __construct(Coordinator $bootstrapCoordinator,
73
-								IServerContainer $container,
74
-								ILogger $logger) {
75
-		$this->container = $container;
76
-		$this->logger = $logger;
77
-		$this->bootstrapCoordinator = $bootstrapCoordinator;
78
-	}
79
-
80
-	/**
81
-	 * Load all providers dynamically that were registered through `registerProvider`
82
-	 *
83
-	 * If a provider can't be loaded we log it but the operation continues nevertheless
84
-	 */
85
-	private function loadLazyProviders(): void {
86
-		$context = $this->bootstrapCoordinator->getRegistrationContext();
87
-		if ($context === null) {
88
-			// Too early, nothing registered yet
89
-			return;
90
-		}
91
-
92
-		$registrations = $context->getSearchProviders();
93
-		foreach ($registrations as $registration) {
94
-			try {
95
-				/** @var IProvider $provider */
96
-				$provider = $this->container->query($registration['class']);
97
-				$this->providers[$provider->getId()] = $provider;
98
-			} catch (QueryException $e) {
99
-				// Log an continue. We can be fault tolerant here.
100
-				$this->logger->logException($e, [
101
-					'message' => 'Could not load search provider dynamically: ' . $e->getMessage(),
102
-					'level' => ILogger::ERROR,
103
-				]);
104
-			}
105
-		}
106
-	}
107
-
108
-	/**
109
-	 * Get a list of all provider IDs & Names for the consecutive calls to `search`
110
-	 *
111
-	 * @return array
112
-	 */
113
-	public function getProviders(): array {
114
-		$this->loadLazyProviders();
115
-
116
-		/**
117
-		 * Return an array with the IDs, but strip the associative keys
118
-		 */
119
-		return array_values(
120
-			array_map(function (IProvider $provider) {
121
-				return [
122
-					'id' => $provider->getId(),
123
-					'name' => $provider->getName()
124
-				];
125
-			}, $this->providers));
126
-	}
127
-
128
-	/**
129
-	 * Query an individual search provider for results
130
-	 *
131
-	 * @param IUser $user
132
-	 * @param string $providerId one of the IDs received by `getProviders`
133
-	 * @param ISearchQuery $query
134
-	 *
135
-	 * @return SearchResult
136
-	 * @throws InvalidArgumentException when the $providerId does not correspond to a registered provider
137
-	 */
138
-	public function search(IUser $user,
139
-						   string $providerId,
140
-						   ISearchQuery $query): SearchResult {
141
-		$this->loadLazyProviders();
142
-
143
-		$provider = $this->providers[$providerId] ?? null;
144
-		if ($provider === null) {
145
-			throw new InvalidArgumentException("Provider $providerId is unknown");
146
-		}
147
-		return $provider->search($user, $query);
148
-	}
60
+    /** @var IProvider[] */
61
+    private $providers = [];
62
+
63
+    /** @var Coordinator */
64
+    private $bootstrapCoordinator;
65
+
66
+    /** @var IServerContainer */
67
+    private $container;
68
+
69
+    /** @var ILogger */
70
+    private $logger;
71
+
72
+    public function __construct(Coordinator $bootstrapCoordinator,
73
+                                IServerContainer $container,
74
+                                ILogger $logger) {
75
+        $this->container = $container;
76
+        $this->logger = $logger;
77
+        $this->bootstrapCoordinator = $bootstrapCoordinator;
78
+    }
79
+
80
+    /**
81
+     * Load all providers dynamically that were registered through `registerProvider`
82
+     *
83
+     * If a provider can't be loaded we log it but the operation continues nevertheless
84
+     */
85
+    private function loadLazyProviders(): void {
86
+        $context = $this->bootstrapCoordinator->getRegistrationContext();
87
+        if ($context === null) {
88
+            // Too early, nothing registered yet
89
+            return;
90
+        }
91
+
92
+        $registrations = $context->getSearchProviders();
93
+        foreach ($registrations as $registration) {
94
+            try {
95
+                /** @var IProvider $provider */
96
+                $provider = $this->container->query($registration['class']);
97
+                $this->providers[$provider->getId()] = $provider;
98
+            } catch (QueryException $e) {
99
+                // Log an continue. We can be fault tolerant here.
100
+                $this->logger->logException($e, [
101
+                    'message' => 'Could not load search provider dynamically: ' . $e->getMessage(),
102
+                    'level' => ILogger::ERROR,
103
+                ]);
104
+            }
105
+        }
106
+    }
107
+
108
+    /**
109
+     * Get a list of all provider IDs & Names for the consecutive calls to `search`
110
+     *
111
+     * @return array
112
+     */
113
+    public function getProviders(): array {
114
+        $this->loadLazyProviders();
115
+
116
+        /**
117
+         * Return an array with the IDs, but strip the associative keys
118
+         */
119
+        return array_values(
120
+            array_map(function (IProvider $provider) {
121
+                return [
122
+                    'id' => $provider->getId(),
123
+                    'name' => $provider->getName()
124
+                ];
125
+            }, $this->providers));
126
+    }
127
+
128
+    /**
129
+     * Query an individual search provider for results
130
+     *
131
+     * @param IUser $user
132
+     * @param string $providerId one of the IDs received by `getProviders`
133
+     * @param ISearchQuery $query
134
+     *
135
+     * @return SearchResult
136
+     * @throws InvalidArgumentException when the $providerId does not correspond to a registered provider
137
+     */
138
+    public function search(IUser $user,
139
+                            string $providerId,
140
+                            ISearchQuery $query): SearchResult {
141
+        $this->loadLazyProviders();
142
+
143
+        $provider = $this->providers[$providerId] ?? null;
144
+        if ($provider === null) {
145
+            throw new InvalidArgumentException("Provider $providerId is unknown");
146
+        }
147
+        return $provider->search($user, $query);
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			} catch (QueryException $e) {
99 99
 				// Log an continue. We can be fault tolerant here.
100 100
 				$this->logger->logException($e, [
101
-					'message' => 'Could not load search provider dynamically: ' . $e->getMessage(),
101
+					'message' => 'Could not load search provider dynamically: '.$e->getMessage(),
102 102
 					'level' => ILogger::ERROR,
103 103
 				]);
104 104
 			}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		 * Return an array with the IDs, but strip the associative keys
118 118
 		 */
119 119
 		return array_values(
120
-			array_map(function (IProvider $provider) {
120
+			array_map(function(IProvider $provider) {
121 121
 				return [
122 122
 					'id' => $provider->getId(),
123 123
 					'name' => $provider->getName()
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 1 patch
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -56,315 +56,315 @@
 block discarded – undo
56 56
 use OCP\Util;
57 57
 
58 58
 class TemplateLayout extends \OC_Template {
59
-	private static $versionHash = '';
60
-
61
-	/** @var IConfig */
62
-	private $config;
63
-
64
-	/** @var IInitialStateService */
65
-	private $initialState;
66
-
67
-	/**
68
-	 * @param string $renderAs
69
-	 * @param string $appId application id
70
-	 */
71
-	public function __construct($renderAs, $appId = '') {
72
-
73
-		/** @var IConfig */
74
-		$this->config = \OC::$server->get(IConfig::class);
75
-
76
-		/** @var IInitialStateService */
77
-		$this->initialState = \OC::$server->get(InitialStateService::class);
78
-
79
-		if (Util::isIE()) {
80
-			Util::addStyle('ie');
81
-		}
82
-
83
-		// Decide which page we show
84
-		if ($renderAs === TemplateResponse::RENDER_AS_USER) {
85
-			parent::__construct('core', 'layout.user');
86
-			if (in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
87
-				$this->assign('bodyid', 'body-settings');
88
-			} else {
89
-				$this->assign('bodyid', 'body-user');
90
-			}
91
-
92
-			$this->initialState->provideInitialState('unified-search', 'limit-default', SearchQuery::LIMIT_DEFAULT);
93
-			Util::addScript('dist/unified-search', null, true);
94
-
95
-			// Add navigation entry
96
-			$this->assign('application', '');
97
-			$this->assign('appid', $appId);
98
-			$navigation = \OC::$server->getNavigationManager()->getAll();
99
-			$this->assign('navigation', $navigation);
100
-			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
101
-			$this->assign('settingsnavigation', $settingsNavigation);
102
-			foreach ($navigation as $entry) {
103
-				if ($entry['active']) {
104
-					$this->assign('application', $entry['name']);
105
-					break;
106
-				}
107
-			}
108
-
109
-			foreach ($settingsNavigation as $entry) {
110
-				if ($entry['active']) {
111
-					$this->assign('application', $entry['name']);
112
-					break;
113
-				}
114
-			}
115
-			$userDisplayName = \OC_User::getDisplayName();
116
-			$this->assign('user_displayname', $userDisplayName);
117
-			$this->assign('user_uid', \OC_User::getUser());
118
-
119
-			if (\OC_User::getUser() === false) {
120
-				$this->assign('userAvatarSet', false);
121
-			} else {
122
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
123
-				$this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
124
-			}
125
-
126
-			// check if app menu icons should be inverted
127
-			try {
128
-				/** @var \OCA\Theming\Util $util */
129
-				$util = \OC::$server->query(\OCA\Theming\Util::class);
130
-				$this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
131
-			} catch (\OCP\AppFramework\QueryException $e) {
132
-				$this->assign('themingInvertMenu', false);
133
-			} catch (\OCP\AutoloadNotAllowedException $e) {
134
-				$this->assign('themingInvertMenu', false);
135
-			}
136
-		} elseif ($renderAs === TemplateResponse::RENDER_AS_ERROR) {
137
-			parent::__construct('core', 'layout.guest', '', false);
138
-			$this->assign('bodyid', 'body-login');
139
-			$this->assign('user_displayname', '');
140
-			$this->assign('user_uid', '');
141
-		} elseif ($renderAs === TemplateResponse::RENDER_AS_GUEST) {
142
-			parent::__construct('core', 'layout.guest');
143
-			\OC_Util::addStyle('guest');
144
-			$this->assign('bodyid', 'body-login');
145
-
146
-			$userDisplayName = \OC_User::getDisplayName();
147
-			$this->assign('user_displayname', $userDisplayName);
148
-			$this->assign('user_uid', \OC_User::getUser());
149
-		} elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) {
150
-			parent::__construct('core', 'layout.public');
151
-			$this->assign('appid', $appId);
152
-			$this->assign('bodyid', 'body-public');
153
-
154
-			/** @var IRegistry $subscription */
155
-			$subscription = \OC::$server->query(IRegistry::class);
156
-			$showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true);
157
-			if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) {
158
-				$showSimpleSignup = false;
159
-			}
160
-			$this->assign('showSimpleSignUpLink', $showSimpleSignup);
161
-		} else {
162
-			parent::__construct('core', 'layout.base');
163
-		}
164
-		// Send the language and the locale to our layouts
165
-		$lang = \OC::$server->getL10NFactory()->findLanguage();
166
-		$locale = \OC::$server->getL10NFactory()->findLocale($lang);
167
-
168
-		$lang = str_replace('_', '-', $lang);
169
-		$this->assign('language', $lang);
170
-		$this->assign('locale', $locale);
171
-
172
-		if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
173
-			if (empty(self::$versionHash)) {
174
-				$v = \OC_App::getAppVersions();
175
-				$v['core'] = implode('.', \OCP\Util::getVersion());
176
-				self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
177
-			}
178
-		} else {
179
-			self::$versionHash = md5('not installed');
180
-		}
181
-
182
-		// Add the js files
183
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
184
-		$this->assign('jsfiles', []);
185
-		if ($this->config->getSystemValue('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) {
186
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
187
-				$jsConfigHelper = new JSConfigHelper(
188
-					\OC::$server->getL10N('lib'),
189
-					\OC::$server->query(Defaults::class),
190
-					\OC::$server->getAppManager(),
191
-					\OC::$server->getSession(),
192
-					\OC::$server->getUserSession()->getUser(),
193
-					$this->config,
194
-					\OC::$server->getGroupManager(),
195
-					\OC::$server->getIniWrapper(),
196
-					\OC::$server->getURLGenerator(),
197
-					\OC::$server->getCapabilitiesManager(),
198
-					\OC::$server->query(IInitialStateService::class)
199
-				);
200
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
201
-			} else {
202
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
203
-			}
204
-		}
205
-		foreach ($jsFiles as $info) {
206
-			$web = $info[1];
207
-			$file = $info[2];
208
-			$this->append('jsfiles', $web.'/'.$file . $this->getVersionHashSuffix());
209
-		}
210
-
211
-		try {
212
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
213
-		} catch (\Exception $e) {
214
-			$pathInfo = '';
215
-		}
216
-
217
-		// Do not initialise scss appdata until we have a fully installed instance
218
-		// Do not load scss for update, errors, installation or login page
219
-		if (\OC::$server->getSystemConfig()->getValue('installed', false)
220
-			&& !\OCP\Util::needUpgrade()
221
-			&& $pathInfo !== ''
222
-			&& !preg_match('/^\/login/', $pathInfo)
223
-			&& $renderAs !== TemplateResponse::RENDER_AS_ERROR
224
-		) {
225
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
226
-		} else {
227
-			// If we ignore the scss compiler,
228
-			// we need to load the guest css fallback
229
-			\OC_Util::addStyle('guest');
230
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
231
-		}
232
-
233
-		$this->assign('cssfiles', []);
234
-		$this->assign('printcssfiles', []);
235
-		$this->assign('versionHash', self::$versionHash);
236
-		foreach ($cssFiles as $info) {
237
-			$web = $info[1];
238
-			$file = $info[2];
239
-
240
-			if (substr($file, -strlen('print.css')) === 'print.css') {
241
-				$this->append('printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix());
242
-			} else {
243
-				$suffix = $this->getVersionHashSuffix($web, $file);
244
-
245
-				if (strpos($file, '?v=') == false) {
246
-					$this->append('cssfiles', $web.'/'.$file . $suffix);
247
-				} else {
248
-					$this->append('cssfiles', $web.'/'.$file . '-' . substr($suffix, 3));
249
-				}
250
-			}
251
-		}
59
+    private static $versionHash = '';
60
+
61
+    /** @var IConfig */
62
+    private $config;
63
+
64
+    /** @var IInitialStateService */
65
+    private $initialState;
66
+
67
+    /**
68
+     * @param string $renderAs
69
+     * @param string $appId application id
70
+     */
71
+    public function __construct($renderAs, $appId = '') {
72
+
73
+        /** @var IConfig */
74
+        $this->config = \OC::$server->get(IConfig::class);
75
+
76
+        /** @var IInitialStateService */
77
+        $this->initialState = \OC::$server->get(InitialStateService::class);
78
+
79
+        if (Util::isIE()) {
80
+            Util::addStyle('ie');
81
+        }
82
+
83
+        // Decide which page we show
84
+        if ($renderAs === TemplateResponse::RENDER_AS_USER) {
85
+            parent::__construct('core', 'layout.user');
86
+            if (in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
87
+                $this->assign('bodyid', 'body-settings');
88
+            } else {
89
+                $this->assign('bodyid', 'body-user');
90
+            }
91
+
92
+            $this->initialState->provideInitialState('unified-search', 'limit-default', SearchQuery::LIMIT_DEFAULT);
93
+            Util::addScript('dist/unified-search', null, true);
94
+
95
+            // Add navigation entry
96
+            $this->assign('application', '');
97
+            $this->assign('appid', $appId);
98
+            $navigation = \OC::$server->getNavigationManager()->getAll();
99
+            $this->assign('navigation', $navigation);
100
+            $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
101
+            $this->assign('settingsnavigation', $settingsNavigation);
102
+            foreach ($navigation as $entry) {
103
+                if ($entry['active']) {
104
+                    $this->assign('application', $entry['name']);
105
+                    break;
106
+                }
107
+            }
108
+
109
+            foreach ($settingsNavigation as $entry) {
110
+                if ($entry['active']) {
111
+                    $this->assign('application', $entry['name']);
112
+                    break;
113
+                }
114
+            }
115
+            $userDisplayName = \OC_User::getDisplayName();
116
+            $this->assign('user_displayname', $userDisplayName);
117
+            $this->assign('user_uid', \OC_User::getUser());
118
+
119
+            if (\OC_User::getUser() === false) {
120
+                $this->assign('userAvatarSet', false);
121
+            } else {
122
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
123
+                $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
124
+            }
125
+
126
+            // check if app menu icons should be inverted
127
+            try {
128
+                /** @var \OCA\Theming\Util $util */
129
+                $util = \OC::$server->query(\OCA\Theming\Util::class);
130
+                $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
131
+            } catch (\OCP\AppFramework\QueryException $e) {
132
+                $this->assign('themingInvertMenu', false);
133
+            } catch (\OCP\AutoloadNotAllowedException $e) {
134
+                $this->assign('themingInvertMenu', false);
135
+            }
136
+        } elseif ($renderAs === TemplateResponse::RENDER_AS_ERROR) {
137
+            parent::__construct('core', 'layout.guest', '', false);
138
+            $this->assign('bodyid', 'body-login');
139
+            $this->assign('user_displayname', '');
140
+            $this->assign('user_uid', '');
141
+        } elseif ($renderAs === TemplateResponse::RENDER_AS_GUEST) {
142
+            parent::__construct('core', 'layout.guest');
143
+            \OC_Util::addStyle('guest');
144
+            $this->assign('bodyid', 'body-login');
145
+
146
+            $userDisplayName = \OC_User::getDisplayName();
147
+            $this->assign('user_displayname', $userDisplayName);
148
+            $this->assign('user_uid', \OC_User::getUser());
149
+        } elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) {
150
+            parent::__construct('core', 'layout.public');
151
+            $this->assign('appid', $appId);
152
+            $this->assign('bodyid', 'body-public');
153
+
154
+            /** @var IRegistry $subscription */
155
+            $subscription = \OC::$server->query(IRegistry::class);
156
+            $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true);
157
+            if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) {
158
+                $showSimpleSignup = false;
159
+            }
160
+            $this->assign('showSimpleSignUpLink', $showSimpleSignup);
161
+        } else {
162
+            parent::__construct('core', 'layout.base');
163
+        }
164
+        // Send the language and the locale to our layouts
165
+        $lang = \OC::$server->getL10NFactory()->findLanguage();
166
+        $locale = \OC::$server->getL10NFactory()->findLocale($lang);
167
+
168
+        $lang = str_replace('_', '-', $lang);
169
+        $this->assign('language', $lang);
170
+        $this->assign('locale', $locale);
171
+
172
+        if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
173
+            if (empty(self::$versionHash)) {
174
+                $v = \OC_App::getAppVersions();
175
+                $v['core'] = implode('.', \OCP\Util::getVersion());
176
+                self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
177
+            }
178
+        } else {
179
+            self::$versionHash = md5('not installed');
180
+        }
181
+
182
+        // Add the js files
183
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
184
+        $this->assign('jsfiles', []);
185
+        if ($this->config->getSystemValue('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) {
186
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
187
+                $jsConfigHelper = new JSConfigHelper(
188
+                    \OC::$server->getL10N('lib'),
189
+                    \OC::$server->query(Defaults::class),
190
+                    \OC::$server->getAppManager(),
191
+                    \OC::$server->getSession(),
192
+                    \OC::$server->getUserSession()->getUser(),
193
+                    $this->config,
194
+                    \OC::$server->getGroupManager(),
195
+                    \OC::$server->getIniWrapper(),
196
+                    \OC::$server->getURLGenerator(),
197
+                    \OC::$server->getCapabilitiesManager(),
198
+                    \OC::$server->query(IInitialStateService::class)
199
+                );
200
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
201
+            } else {
202
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
203
+            }
204
+        }
205
+        foreach ($jsFiles as $info) {
206
+            $web = $info[1];
207
+            $file = $info[2];
208
+            $this->append('jsfiles', $web.'/'.$file . $this->getVersionHashSuffix());
209
+        }
210
+
211
+        try {
212
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
213
+        } catch (\Exception $e) {
214
+            $pathInfo = '';
215
+        }
216
+
217
+        // Do not initialise scss appdata until we have a fully installed instance
218
+        // Do not load scss for update, errors, installation or login page
219
+        if (\OC::$server->getSystemConfig()->getValue('installed', false)
220
+            && !\OCP\Util::needUpgrade()
221
+            && $pathInfo !== ''
222
+            && !preg_match('/^\/login/', $pathInfo)
223
+            && $renderAs !== TemplateResponse::RENDER_AS_ERROR
224
+        ) {
225
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
226
+        } else {
227
+            // If we ignore the scss compiler,
228
+            // we need to load the guest css fallback
229
+            \OC_Util::addStyle('guest');
230
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
231
+        }
232
+
233
+        $this->assign('cssfiles', []);
234
+        $this->assign('printcssfiles', []);
235
+        $this->assign('versionHash', self::$versionHash);
236
+        foreach ($cssFiles as $info) {
237
+            $web = $info[1];
238
+            $file = $info[2];
239
+
240
+            if (substr($file, -strlen('print.css')) === 'print.css') {
241
+                $this->append('printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix());
242
+            } else {
243
+                $suffix = $this->getVersionHashSuffix($web, $file);
244
+
245
+                if (strpos($file, '?v=') == false) {
246
+                    $this->append('cssfiles', $web.'/'.$file . $suffix);
247
+                } else {
248
+                    $this->append('cssfiles', $web.'/'.$file . '-' . substr($suffix, 3));
249
+                }
250
+            }
251
+        }
252 252
 		
253
-		$this->assign('initialStates', $this->initialState->getInitialStates());
254
-	}
255
-
256
-	/**
257
-	 * @param string $path
258
-	 * @param string $file
259
-	 * @return string
260
-	 */
261
-	protected function getVersionHashSuffix($path = false, $file = false) {
262
-		if ($this->config->getSystemValue('debug', false)) {
263
-			// allows chrome workspace mapping in debug mode
264
-			return "";
265
-		}
266
-		$themingSuffix = '';
267
-		$v = [];
268
-
269
-		if ($this->config->getSystemValue('installed', false)) {
270
-			if (\OC::$server->getAppManager()->isInstalled('theming')) {
271
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
272
-			}
273
-			$v = \OC_App::getAppVersions();
274
-		}
275
-
276
-		// Try the webroot path for a match
277
-		if ($path !== false && $path !== '') {
278
-			$appName = $this->getAppNamefromPath($path);
279
-			if (array_key_exists($appName, $v)) {
280
-				$appVersion = $v[$appName];
281
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
282
-			}
283
-		}
284
-		// fallback to the file path instead
285
-		if ($file !== false && $file !== '') {
286
-			$appName = $this->getAppNamefromPath($file);
287
-			if (array_key_exists($appName, $v)) {
288
-				$appVersion = $v[$appName];
289
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
290
-			}
291
-		}
292
-
293
-		return '?v=' . self::$versionHash . $themingSuffix;
294
-	}
295
-
296
-	/**
297
-	 * @param array $styles
298
-	 * @return array
299
-	 */
300
-	public static function findStylesheetFiles($styles, $compileScss = true) {
301
-		// Read the selected theme from the config file
302
-		$theme = \OC_Util::getTheme();
303
-
304
-		if ($compileScss) {
305
-			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
306
-		} else {
307
-			$SCSSCacher = null;
308
-		}
309
-
310
-		$locator = new \OC\Template\CSSResourceLocator(
311
-			\OC::$server->getLogger(),
312
-			$theme,
313
-			[ \OC::$SERVERROOT => \OC::$WEBROOT ],
314
-			[ \OC::$SERVERROOT => \OC::$WEBROOT ],
315
-			$SCSSCacher
316
-		);
317
-		$locator->find($styles);
318
-		return $locator->getResources();
319
-	}
320
-
321
-	/**
322
-	 * @param string $path
323
-	 * @return string|boolean
324
-	 */
325
-	public function getAppNamefromPath($path) {
326
-		if ($path !== '' && is_string($path)) {
327
-			$pathParts = explode('/', $path);
328
-			if ($pathParts[0] === 'css') {
329
-				// This is a scss request
330
-				return $pathParts[1];
331
-			}
332
-			return end($pathParts);
333
-		}
334
-		return false;
335
-	}
336
-
337
-	/**
338
-	 * @param array $scripts
339
-	 * @return array
340
-	 */
341
-	public static function findJavascriptFiles($scripts) {
342
-		// Read the selected theme from the config file
343
-		$theme = \OC_Util::getTheme();
344
-
345
-		$locator = new \OC\Template\JSResourceLocator(
346
-			\OC::$server->getLogger(),
347
-			$theme,
348
-			[ \OC::$SERVERROOT => \OC::$WEBROOT ],
349
-			[ \OC::$SERVERROOT => \OC::$WEBROOT ],
350
-			\OC::$server->query(JSCombiner::class)
351
-			);
352
-		$locator->find($scripts);
353
-		return $locator->getResources();
354
-	}
355
-
356
-	/**
357
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
358
-	 * @param string $filePath Absolute path
359
-	 * @return string Relative path
360
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
361
-	 */
362
-	public static function convertToRelativePath($filePath) {
363
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
364
-		if (count($relativePath) !== 2) {
365
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
366
-		}
367
-
368
-		return $relativePath[1];
369
-	}
253
+        $this->assign('initialStates', $this->initialState->getInitialStates());
254
+    }
255
+
256
+    /**
257
+     * @param string $path
258
+     * @param string $file
259
+     * @return string
260
+     */
261
+    protected function getVersionHashSuffix($path = false, $file = false) {
262
+        if ($this->config->getSystemValue('debug', false)) {
263
+            // allows chrome workspace mapping in debug mode
264
+            return "";
265
+        }
266
+        $themingSuffix = '';
267
+        $v = [];
268
+
269
+        if ($this->config->getSystemValue('installed', false)) {
270
+            if (\OC::$server->getAppManager()->isInstalled('theming')) {
271
+                $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
272
+            }
273
+            $v = \OC_App::getAppVersions();
274
+        }
275
+
276
+        // Try the webroot path for a match
277
+        if ($path !== false && $path !== '') {
278
+            $appName = $this->getAppNamefromPath($path);
279
+            if (array_key_exists($appName, $v)) {
280
+                $appVersion = $v[$appName];
281
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
282
+            }
283
+        }
284
+        // fallback to the file path instead
285
+        if ($file !== false && $file !== '') {
286
+            $appName = $this->getAppNamefromPath($file);
287
+            if (array_key_exists($appName, $v)) {
288
+                $appVersion = $v[$appName];
289
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
290
+            }
291
+        }
292
+
293
+        return '?v=' . self::$versionHash . $themingSuffix;
294
+    }
295
+
296
+    /**
297
+     * @param array $styles
298
+     * @return array
299
+     */
300
+    public static function findStylesheetFiles($styles, $compileScss = true) {
301
+        // Read the selected theme from the config file
302
+        $theme = \OC_Util::getTheme();
303
+
304
+        if ($compileScss) {
305
+            $SCSSCacher = \OC::$server->query(SCSSCacher::class);
306
+        } else {
307
+            $SCSSCacher = null;
308
+        }
309
+
310
+        $locator = new \OC\Template\CSSResourceLocator(
311
+            \OC::$server->getLogger(),
312
+            $theme,
313
+            [ \OC::$SERVERROOT => \OC::$WEBROOT ],
314
+            [ \OC::$SERVERROOT => \OC::$WEBROOT ],
315
+            $SCSSCacher
316
+        );
317
+        $locator->find($styles);
318
+        return $locator->getResources();
319
+    }
320
+
321
+    /**
322
+     * @param string $path
323
+     * @return string|boolean
324
+     */
325
+    public function getAppNamefromPath($path) {
326
+        if ($path !== '' && is_string($path)) {
327
+            $pathParts = explode('/', $path);
328
+            if ($pathParts[0] === 'css') {
329
+                // This is a scss request
330
+                return $pathParts[1];
331
+            }
332
+            return end($pathParts);
333
+        }
334
+        return false;
335
+    }
336
+
337
+    /**
338
+     * @param array $scripts
339
+     * @return array
340
+     */
341
+    public static function findJavascriptFiles($scripts) {
342
+        // Read the selected theme from the config file
343
+        $theme = \OC_Util::getTheme();
344
+
345
+        $locator = new \OC\Template\JSResourceLocator(
346
+            \OC::$server->getLogger(),
347
+            $theme,
348
+            [ \OC::$SERVERROOT => \OC::$WEBROOT ],
349
+            [ \OC::$SERVERROOT => \OC::$WEBROOT ],
350
+            \OC::$server->query(JSCombiner::class)
351
+            );
352
+        $locator->find($scripts);
353
+        return $locator->getResources();
354
+    }
355
+
356
+    /**
357
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
358
+     * @param string $filePath Absolute path
359
+     * @return string Relative path
360
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
361
+     */
362
+    public static function convertToRelativePath($filePath) {
363
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
364
+        if (count($relativePath) !== 2) {
365
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
366
+        }
367
+
368
+        return $relativePath[1];
369
+    }
370 370
 }
Please login to merge, or discard this patch.
apps/files/lib/Search/FilesSearchResultEntry.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
 use OCP\Search\ASearchResultEntry;
29 29
 
30 30
 class FilesSearchResultEntry extends ASearchResultEntry {
31
-	public function __construct(string $thumbnailUrl,
32
-								string $filename,
33
-								string $path,
34
-								string $url,
35
-								string $icon) {
36
-		parent::__construct($thumbnailUrl, $filename, $path, $url, $icon, false);
37
-	}
31
+    public function __construct(string $thumbnailUrl,
32
+                                string $filename,
33
+                                string $path,
34
+                                string $url,
35
+                                string $icon) {
36
+        parent::__construct($thumbnailUrl, $filename, $path, $url, $icon, false);
37
+    }
38 38
 }
Please login to merge, or discard this patch.
apps/files/lib/Search/FilesSearchProvider.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -36,64 +36,64 @@
 block discarded – undo
36 36
 
37 37
 class FilesSearchProvider implements IProvider {
38 38
 
39
-	/** @var File */
40
-	private $fileSearch;
39
+    /** @var File */
40
+    private $fileSearch;
41 41
 
42
-	/** @var IL10N */
43
-	private $l10n;
42
+    /** @var IL10N */
43
+    private $l10n;
44 44
 
45
-	/** @var IURLGenerator */
46
-	private $urlGenerator;
45
+    /** @var IURLGenerator */
46
+    private $urlGenerator;
47 47
 
48
-	public function __construct(File $fileSearch,
49
-								IL10N $l10n,
50
-								IURLGenerator $urlGenerator) {
51
-		$this->l10n = $l10n;
52
-		$this->fileSearch = $fileSearch;
53
-		$this->urlGenerator = $urlGenerator;
54
-	}
48
+    public function __construct(File $fileSearch,
49
+                                IL10N $l10n,
50
+                                IURLGenerator $urlGenerator) {
51
+        $this->l10n = $l10n;
52
+        $this->fileSearch = $fileSearch;
53
+        $this->urlGenerator = $urlGenerator;
54
+    }
55 55
 
56
-	public function getId(): string {
57
-		return 'files';
58
-	}
56
+    public function getId(): string {
57
+        return 'files';
58
+    }
59 59
 
60
-	public function getName(): string {
61
-		return $this->l10n->t('Files');
62
-	}
60
+    public function getName(): string {
61
+        return $this->l10n->t('Files');
62
+    }
63 63
 
64
-	public function search(IUser $user, ISearchQuery $query): SearchResult {
65
-		return SearchResult::complete(
66
-			$this->l10n->t('Files'),
67
-			array_map(function (FileResult $result) {
68
-				// Generate thumbnail url
69
-				$thumbnailUrl = $result->type === 'folder'
70
-					? ''
71
-					: $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]);
64
+    public function search(IUser $user, ISearchQuery $query): SearchResult {
65
+        return SearchResult::complete(
66
+            $this->l10n->t('Files'),
67
+            array_map(function (FileResult $result) {
68
+                // Generate thumbnail url
69
+                $thumbnailUrl = $result->type === 'folder'
70
+                    ? ''
71
+                    : $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]);
72 72
 
73
-				return new FilesSearchResultEntry(
74
-					$thumbnailUrl,
75
-					$result->name,
76
-					$this->formatSubline($result),
77
-					$result->link,
78
-					$result->type === 'folder' ? 'icon-folder' : 'icon-filetype-file'
79
-				);
80
-			}, $this->fileSearch->search($query->getTerm()))
81
-		);
82
-	}
73
+                return new FilesSearchResultEntry(
74
+                    $thumbnailUrl,
75
+                    $result->name,
76
+                    $this->formatSubline($result),
77
+                    $result->link,
78
+                    $result->type === 'folder' ? 'icon-folder' : 'icon-filetype-file'
79
+                );
80
+            }, $this->fileSearch->search($query->getTerm()))
81
+        );
82
+    }
83 83
 
84
-	/**
85
-	 * Format subline for files
86
-	 *
87
-	 * @param FileResult $result
88
-	 * @return string
89
-	 */
90
-	private function formatSubline($result): string {
91
-		// Do not show the location if the file is in root
92
-		if ($result->path === '/' . $result->name) {
93
-			return '';
94
-		}
84
+    /**
85
+     * Format subline for files
86
+     *
87
+     * @param FileResult $result
88
+     * @return string
89
+     */
90
+    private function formatSubline($result): string {
91
+        // Do not show the location if the file is in root
92
+        if ($result->path === '/' . $result->name) {
93
+            return '';
94
+        }
95 95
 
96
-		$path = ltrim(dirname($result->path), '/');
97
-		return $this->l10n->t('in %s', [$path]);
98
-	}
96
+        $path = ltrim(dirname($result->path), '/');
97
+        return $this->l10n->t('in %s', [$path]);
98
+    }
99 99
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	public function search(IUser $user, ISearchQuery $query): SearchResult {
65 65
 		return SearchResult::complete(
66 66
 			$this->l10n->t('Files'),
67
-			array_map(function (FileResult $result) {
67
+			array_map(function(FileResult $result) {
68 68
 				// Generate thumbnail url
69 69
 				$thumbnailUrl = $result->type === 'folder'
70 70
 					? ''
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	private function formatSubline($result): string {
91 91
 		// Do not show the location if the file is in root
92
-		if ($result->path === '/' . $result->name) {
92
+		if ($result->path === '/'.$result->name) {
93 93
 			return '';
94 94
 		}
95 95
 
Please login to merge, or discard this patch.
apps/comments/lib/Search/Provider.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -37,58 +37,58 @@
 block discarded – undo
37 37
 
38 38
 class Provider implements IProvider {
39 39
 
40
-	/** @var IUserManager */
41
-	private $userManager;
40
+    /** @var IUserManager */
41
+    private $userManager;
42 42
 
43
-	/** @var IL10N */
44
-	private $l10n;
43
+    /** @var IL10N */
44
+    private $l10n;
45 45
 
46
-	/** @var IURLGenerator */
47
-	private $urlGenerator;
46
+    /** @var IURLGenerator */
47
+    private $urlGenerator;
48 48
 
49
-	/** @var LegacyProvider */
50
-	private $legacyProvider;
49
+    /** @var LegacyProvider */
50
+    private $legacyProvider;
51 51
 
52
-	public function __construct(IUserManager $userManager,
53
-								IL10N $l10n,
54
-								IURLGenerator $urlGenerator,
55
-								LegacyProvider $legacyProvider) {
56
-		$this->userManager = $userManager;
57
-		$this->l10n = $l10n;
58
-		$this->urlGenerator = $urlGenerator;
59
-		$this->legacyProvider = $legacyProvider;
60
-	}
52
+    public function __construct(IUserManager $userManager,
53
+                                IL10N $l10n,
54
+                                IURLGenerator $urlGenerator,
55
+                                LegacyProvider $legacyProvider) {
56
+        $this->userManager = $userManager;
57
+        $this->l10n = $l10n;
58
+        $this->urlGenerator = $urlGenerator;
59
+        $this->legacyProvider = $legacyProvider;
60
+    }
61 61
 
62
-	public function getId(): string {
63
-		return 'comments';
64
-	}
62
+    public function getId(): string {
63
+        return 'comments';
64
+    }
65 65
 
66
-	public function getName(): string {
67
-		return $this->l10n->t('Comments');
68
-	}
66
+    public function getName(): string {
67
+        return $this->l10n->t('Comments');
68
+    }
69 69
 
70
-	public function search(IUser $user, ISearchQuery $query): SearchResult {
71
-		return SearchResult::complete(
72
-			$this->l10n->t('Comments'),
73
-			array_map(function (Result $result) {
74
-				$path = $result->path;
75
-				$pathInfo = pathinfo($path);
76
-				$isUser = $this->userManager->userExists($result->authorId);
77
-				$avatarUrl = $isUser
78
-					? $this->urlGenerator->linkToRoute('core.avatar.getAvatar', ['userId' => $result->authorId, 'size' => 42])
79
-					: $this->urlGenerator->linkToRoute('core.GuestAvatar.getAvatar', ['guestName' => $result->authorId, 'size' => 42]);
80
-				return new CommentsSearchResultEntry(
81
-					$avatarUrl,
82
-					$result->name,
83
-					$path,
84
-					$this->urlGenerator->linkToRoute('files.view.index',[
85
-						'dir' => $pathInfo['dirname'],
86
-						'scrollto' => $pathInfo['basename'],
87
-					]),
88
-					'',
89
-					true
90
-				);
91
-			}, $this->legacyProvider->search($query->getTerm()))
92
-		);
93
-	}
70
+    public function search(IUser $user, ISearchQuery $query): SearchResult {
71
+        return SearchResult::complete(
72
+            $this->l10n->t('Comments'),
73
+            array_map(function (Result $result) {
74
+                $path = $result->path;
75
+                $pathInfo = pathinfo($path);
76
+                $isUser = $this->userManager->userExists($result->authorId);
77
+                $avatarUrl = $isUser
78
+                    ? $this->urlGenerator->linkToRoute('core.avatar.getAvatar', ['userId' => $result->authorId, 'size' => 42])
79
+                    : $this->urlGenerator->linkToRoute('core.GuestAvatar.getAvatar', ['guestName' => $result->authorId, 'size' => 42]);
80
+                return new CommentsSearchResultEntry(
81
+                    $avatarUrl,
82
+                    $result->name,
83
+                    $path,
84
+                    $this->urlGenerator->linkToRoute('files.view.index',[
85
+                        'dir' => $pathInfo['dirname'],
86
+                        'scrollto' => $pathInfo['basename'],
87
+                    ]),
88
+                    '',
89
+                    true
90
+                );
91
+            }, $this->legacyProvider->search($query->getTerm()))
92
+        );
93
+    }
94 94
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	public function search(IUser $user, ISearchQuery $query): SearchResult {
71 71
 		return SearchResult::complete(
72 72
 			$this->l10n->t('Comments'),
73
-			array_map(function (Result $result) {
73
+			array_map(function(Result $result) {
74 74
 				$path = $result->path;
75 75
 				$pathInfo = pathinfo($path);
76 76
 				$isUser = $this->userManager->userExists($result->authorId);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 					$avatarUrl,
82 82
 					$result->name,
83 83
 					$path,
84
-					$this->urlGenerator->linkToRoute('files.view.index',[
84
+					$this->urlGenerator->linkToRoute('files.view.index', [
85 85
 						'dir' => $pathInfo['dirname'],
86 86
 						'scrollto' => $pathInfo['basename'],
87 87
 					]),
Please login to merge, or discard this patch.
core/templates/layout.user.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 		<meta charset="utf-8">
5 5
 		<title>
6 6
 			<?php
7
-				p(!empty($_['application'])?$_['application'].' - ':'');
7
+				p(!empty($_['application']) ? $_['application'].' - ' : '');
8 8
 				p($theme->getTitle());
9 9
 			?>
10 10
 		</title>
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		<?php } ?>
16 16
 		<meta name="apple-mobile-web-app-capable" content="yes">
17 17
 		<meta name="apple-mobile-web-app-status-bar-style" content="black">
18
-		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid']!='files')? $_['application']:$theme->getTitle()); ?>">
18
+		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files') ? $_['application'] : $theme->getTitle()); ?>">
19 19
 		<meta name="mobile-web-app-capable" content="yes">
20 20
 		<meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>">
21 21
 		<link rel="icon" href="<?php print_unescaped(image_path($_['appid'], 'favicon.ico')); /* IE11+ supports png */ ?>">
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		<?php emit_script_loading_tags($_); ?>
27 27
 		<?php print_unescaped($_['headers']); ?>
28 28
 	</head>
29
-	<body id="<?php p($_['bodyid']);?>">
29
+	<body id="<?php p($_['bodyid']); ?>">
30 30
 	<?php include 'layout.noscript.warning.php'; ?>
31 31
 
32 32
 		<?php foreach ($_['initialStates'] as $app => $initialState) { ?>
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 					id="nextcloud">
46 46
 					<div class="logo logo-icon">
47 47
 						<h1 class="hidden-visually">
48
-							<?php p($theme->getName()); ?> <?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?>
48
+							<?php p($theme->getName()); ?> <?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?>
49 49
 						</h1>
50 50
 					</div>
51 51
 				</a>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 										<?php if ($_['themingInvertMenu']) { ?>
61 61
 										<defs><filter id="invertMenuMain-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" /></filter></defs>
62 62
 										<?php } ?>
63
-										<image x="0" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet"<?php if ($_['themingInvertMenu']) { ?> filter="url(#invertMenuMain-<?php p($entry['id']); ?>)"<?php } ?> xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
63
+										<image x="0" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet"<?php if ($_['themingInvertMenu']) { ?> filter="url(#invertMenuMain-<?php p($entry['id']); ?>)"<?php } ?> xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
64 64
 									</svg>
65 65
 								<span>
66 66
 									<?php p($entry['name']); ?>
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 										aria-label="<?php p($entry['name']); ?>">
89 89
 										<svg width="16" height="16" viewBox="0 0 16 16" alt="">
90 90
 											<defs><filter id="invertMenuMore-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
91
-											<image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invertMenuMore-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
91
+											<image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invertMenuMore-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
92 92
 										</svg>
93 93
 										<span><?php p($entry['name']); ?></span>
94 94
 									</a>
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 				<div id="contactsmenu">
107 107
 					<div class="icon-contacts menutoggle" tabindex="0" role="button"
108 108
 					aria-haspopup="true" aria-controls="contactsmenu-menu" aria-expanded="false">
109
-						<span class="hidden-visually"><?php p($l->t('Contacts'));?></span>
109
+						<span class="hidden-visually"><?php p($l->t('Contacts')); ?></span>
110 110
 					</div>
111 111
 					<div id="contactsmenu-menu" class="menu"
112
-						aria-label="<?php p($l->t('Contacts menu'));?>"></div>
112
+						aria-label="<?php p($l->t('Contacts menu')); ?>"></div>
113 113
 				</div>
114 114
 				<div id="settings">
115 115
 					<div id="expand" tabindex="0" role="button" class="menutoggle"
116
-						aria-label="<?php p($l->t('Settings'));?>"
116
+						aria-label="<?php p($l->t('Settings')); ?>"
117 117
 						aria-haspopup="true" aria-controls="expanddiv" aria-expanded="false">
118 118
 						<div class="avatardiv<?php if ($_['userAvatarSet']) {
119 119
 				print_unescaped(' avatardiv-shown');
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 			} ?>">
123 123
 							<?php if ($_['userAvatarSet']): ?>
124 124
 								<img alt="" width="32" height="32"
125
-								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']]));?>"
126
-								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']]));?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']]));?> 4x"
125
+								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']])); ?>"
126
+								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']])); ?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']])); ?> 4x"
127 127
 								>
128 128
 							<?php endif; ?>
129 129
 						</div>
130 130
 						<div id="expandDisplayName" class="icon-settings-white"></div>
131 131
 					</div>
132 132
 					<nav class="settings-menu" id="expanddiv" style="display:none;"
133
-						aria-label="<?php p($l->t('Settings menu'));?>">
133
+						aria-label="<?php p($l->t('Settings menu')); ?>">
134 134
 					<ul>
135 135
 					<?php foreach ($_['settingsnavigation'] as $entry):?>
136 136
 						<li data-id="<?php p($entry['id']); ?>">
137 137
 							<a href="<?php print_unescaped($entry['href']); ?>"
138 138
 								<?php if ($entry["active"]): ?> class="active"<?php endif; ?>>
139
-								<img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>">
139
+								<img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>">
140 140
 								<?php p($entry['name']) ?>
141 141
 							</a>
142 142
 						</li>
Please login to merge, or discard this patch.