Completed
Pull Request — master (#9895)
by Björn
43:43 queued 13:05
created
lib/private/User/Backend.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -29,136 +29,136 @@
 block discarded – undo
29 29
  * capabilities.
30 30
  */
31 31
 abstract class Backend implements UserInterface {
32
-	/**
33
-	 * error code for functions not provided by the user backend
34
-	 */
35
-	const NOT_IMPLEMENTED = -501;
32
+    /**
33
+     * error code for functions not provided by the user backend
34
+     */
35
+    const NOT_IMPLEMENTED = -501;
36 36
 
37
-	/**
38
-	 * actions that user backends can define
39
-	 */
40
-	const CREATE_USER		= 1;			// 1 << 0
41
-	const SET_PASSWORD		= 16;			// 1 << 4
42
-	const CHECK_PASSWORD	= 256;			// 1 << 8
43
-	const GET_HOME			= 4096;			// 1 << 12
44
-	const GET_DISPLAYNAME	= 65536;		// 1 << 16
45
-	const SET_DISPLAYNAME	= 1048576;		// 1 << 20
46
-	const PROVIDE_AVATAR	= 16777216;		// 1 << 24
47
-	const COUNT_USERS		= 268435456;	// 1 << 28
37
+    /**
38
+     * actions that user backends can define
39
+     */
40
+    const CREATE_USER		= 1;			// 1 << 0
41
+    const SET_PASSWORD		= 16;			// 1 << 4
42
+    const CHECK_PASSWORD	= 256;			// 1 << 8
43
+    const GET_HOME			= 4096;			// 1 << 12
44
+    const GET_DISPLAYNAME	= 65536;		// 1 << 16
45
+    const SET_DISPLAYNAME	= 1048576;		// 1 << 20
46
+    const PROVIDE_AVATAR	= 16777216;		// 1 << 24
47
+    const COUNT_USERS		= 268435456;	// 1 << 28
48 48
 
49
-	protected $possibleActions = array(
50
-		self::CREATE_USER => 'createUser',
51
-		self::SET_PASSWORD => 'setPassword',
52
-		self::CHECK_PASSWORD => 'checkPassword',
53
-		self::GET_HOME => 'getHome',
54
-		self::GET_DISPLAYNAME => 'getDisplayName',
55
-		self::SET_DISPLAYNAME => 'setDisplayName',
56
-		self::PROVIDE_AVATAR => 'canChangeAvatar',
57
-		self::COUNT_USERS => 'countUsers',
58
-	);
49
+    protected $possibleActions = array(
50
+        self::CREATE_USER => 'createUser',
51
+        self::SET_PASSWORD => 'setPassword',
52
+        self::CHECK_PASSWORD => 'checkPassword',
53
+        self::GET_HOME => 'getHome',
54
+        self::GET_DISPLAYNAME => 'getDisplayName',
55
+        self::SET_DISPLAYNAME => 'setDisplayName',
56
+        self::PROVIDE_AVATAR => 'canChangeAvatar',
57
+        self::COUNT_USERS => 'countUsers',
58
+    );
59 59
 
60
-	/**
61
-	* Get all supported actions
62
-	* @return int bitwise-or'ed actions
63
-	*
64
-	* Returns the supported actions as int to be
65
-	* compared with self::CREATE_USER etc.
66
-	*/
67
-	public function getSupportedActions() {
68
-		$actions = 0;
69
-		foreach($this->possibleActions AS $action => $methodName) {
70
-			if(method_exists($this, $methodName)) {
71
-				$actions |= $action;
72
-			}
73
-		}
60
+    /**
61
+     * Get all supported actions
62
+     * @return int bitwise-or'ed actions
63
+     *
64
+     * Returns the supported actions as int to be
65
+     * compared with self::CREATE_USER etc.
66
+     */
67
+    public function getSupportedActions() {
68
+        $actions = 0;
69
+        foreach($this->possibleActions AS $action => $methodName) {
70
+            if(method_exists($this, $methodName)) {
71
+                $actions |= $action;
72
+            }
73
+        }
74 74
 
75
-		return $actions;
76
-	}
75
+        return $actions;
76
+    }
77 77
 
78
-	/**
79
-	* Check if backend implements actions
80
-	* @param int $actions bitwise-or'ed actions
81
-	* @return boolean
82
-	*
83
-	* Returns the supported actions as int to be
84
-	* compared with self::CREATE_USER etc.
85
-	*/
86
-	public function implementsActions($actions) {
87
-		return (bool)($this->getSupportedActions() & $actions);
88
-	}
78
+    /**
79
+     * Check if backend implements actions
80
+     * @param int $actions bitwise-or'ed actions
81
+     * @return boolean
82
+     *
83
+     * Returns the supported actions as int to be
84
+     * compared with self::CREATE_USER etc.
85
+     */
86
+    public function implementsActions($actions) {
87
+        return (bool)($this->getSupportedActions() & $actions);
88
+    }
89 89
 
90
-	/**
91
-	 * delete a user
92
-	 * @param string $uid The username of the user to delete
93
-	 * @return bool
94
-	 *
95
-	 * Deletes a user
96
-	 */
97
-	public function deleteUser( $uid ) {
98
-		return false;
99
-	}
90
+    /**
91
+     * delete a user
92
+     * @param string $uid The username of the user to delete
93
+     * @return bool
94
+     *
95
+     * Deletes a user
96
+     */
97
+    public function deleteUser( $uid ) {
98
+        return false;
99
+    }
100 100
 
101
-	/**
102
-	 * Get a list of all users
103
-	 *
104
-	 * @param string $search
105
-	 * @param null|int $limit
106
-	 * @param null|int $offset
107
-	 * @return string[] an array of all uids
108
-	 */
109
-	public function getUsers($search = '', $limit = null, $offset = null) {
110
-		return array();
111
-	}
101
+    /**
102
+     * Get a list of all users
103
+     *
104
+     * @param string $search
105
+     * @param null|int $limit
106
+     * @param null|int $offset
107
+     * @return string[] an array of all uids
108
+     */
109
+    public function getUsers($search = '', $limit = null, $offset = null) {
110
+        return array();
111
+    }
112 112
 
113
-	/**
114
-	* check if a user exists
115
-	* @param string $uid the username
116
-	* @return boolean
117
-	*/
118
-	public function userExists($uid) {
119
-		return false;
120
-	}
113
+    /**
114
+     * check if a user exists
115
+     * @param string $uid the username
116
+     * @return boolean
117
+     */
118
+    public function userExists($uid) {
119
+        return false;
120
+    }
121 121
 
122
-	/**
123
-	* get the user's home directory
124
-	* @param string $uid the username
125
-	* @return boolean
126
-	*/
127
-	public function getHome($uid) {
128
-		return false;
129
-	}
122
+    /**
123
+     * get the user's home directory
124
+     * @param string $uid the username
125
+     * @return boolean
126
+     */
127
+    public function getHome($uid) {
128
+        return false;
129
+    }
130 130
 
131
-	/**
132
-	 * get display name of the user
133
-	 * @param string $uid user ID of the user
134
-	 * @return string display name
135
-	 */
136
-	public function getDisplayName($uid) {
137
-		return $uid;
138
-	}
131
+    /**
132
+     * get display name of the user
133
+     * @param string $uid user ID of the user
134
+     * @return string display name
135
+     */
136
+    public function getDisplayName($uid) {
137
+        return $uid;
138
+    }
139 139
 
140
-	/**
141
-	 * Get a list of all display names and user ids.
142
-	 *
143
-	 * @param string $search
144
-	 * @param string|null $limit
145
-	 * @param string|null $offset
146
-	 * @return array an array of all displayNames (value) and the corresponding uids (key)
147
-	 */
148
-	public function getDisplayNames($search = '', $limit = null, $offset = null) {
149
-		$displayNames = array();
150
-		$users = $this->getUsers($search, $limit, $offset);
151
-		foreach ( $users as $user) {
152
-			$displayNames[$user] = $user;
153
-		}
154
-		return $displayNames;
155
-	}
140
+    /**
141
+     * Get a list of all display names and user ids.
142
+     *
143
+     * @param string $search
144
+     * @param string|null $limit
145
+     * @param string|null $offset
146
+     * @return array an array of all displayNames (value) and the corresponding uids (key)
147
+     */
148
+    public function getDisplayNames($search = '', $limit = null, $offset = null) {
149
+        $displayNames = array();
150
+        $users = $this->getUsers($search, $limit, $offset);
151
+        foreach ( $users as $user) {
152
+            $displayNames[$user] = $user;
153
+        }
154
+        return $displayNames;
155
+    }
156 156
 
157
-	/**
158
-	 * Check if a user list is available or not
159
-	 * @return boolean if users can be listed or not
160
-	 */
161
-	public function hasUserListings() {
162
-		return false;
163
-	}
157
+    /**
158
+     * Check if a user list is available or not
159
+     * @return boolean if users can be listed or not
160
+     */
161
+    public function hasUserListings() {
162
+        return false;
163
+    }
164 164
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * actions that user backends can define
39 39
 	 */
40
-	const CREATE_USER		= 1;			// 1 << 0
41
-	const SET_PASSWORD		= 16;			// 1 << 4
42
-	const CHECK_PASSWORD	= 256;			// 1 << 8
43
-	const GET_HOME			= 4096;			// 1 << 12
44
-	const GET_DISPLAYNAME	= 65536;		// 1 << 16
45
-	const SET_DISPLAYNAME	= 1048576;		// 1 << 20
46
-	const PROVIDE_AVATAR	= 16777216;		// 1 << 24
47
-	const COUNT_USERS		= 268435456;	// 1 << 28
40
+	const CREATE_USER = 1; // 1 << 0
41
+	const SET_PASSWORD = 16; // 1 << 4
42
+	const CHECK_PASSWORD = 256; // 1 << 8
43
+	const GET_HOME = 4096; // 1 << 12
44
+	const GET_DISPLAYNAME	= 65536; // 1 << 16
45
+	const SET_DISPLAYNAME	= 1048576; // 1 << 20
46
+	const PROVIDE_AVATAR = 16777216; // 1 << 24
47
+	const COUNT_USERS = 268435456; // 1 << 28
48 48
 
49 49
 	protected $possibleActions = array(
50 50
 		self::CREATE_USER => 'createUser',
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	*/
67 67
 	public function getSupportedActions() {
68 68
 		$actions = 0;
69
-		foreach($this->possibleActions AS $action => $methodName) {
70
-			if(method_exists($this, $methodName)) {
69
+		foreach ($this->possibleActions AS $action => $methodName) {
70
+			if (method_exists($this, $methodName)) {
71 71
 				$actions |= $action;
72 72
 			}
73 73
 		}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	* compared with self::CREATE_USER etc.
85 85
 	*/
86 86
 	public function implementsActions($actions) {
87
-		return (bool)($this->getSupportedActions() & $actions);
87
+		return (bool) ($this->getSupportedActions() & $actions);
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * Deletes a user
96 96
 	 */
97
-	public function deleteUser( $uid ) {
97
+	public function deleteUser($uid) {
98 98
 		return false;
99 99
 	}
100 100
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	public function getDisplayNames($search = '', $limit = null, $offset = null) {
149 149
 		$displayNames = array();
150 150
 		$users = $this->getUsers($search, $limit, $offset);
151
-		foreach ( $users as $user) {
151
+		foreach ($users as $user) {
152 152
 			$displayNames[$user] = $user;
153 153
 		}
154 154
 		return $displayNames;
Please login to merge, or discard this patch.
lib/private/Diagnostics/Event.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -26,79 +26,79 @@
 block discarded – undo
26 26
 use OCP\Diagnostics\IEvent;
27 27
 
28 28
 class Event implements IEvent {
29
-	/**
30
-	 * @var string
31
-	 */
32
-	protected $id;
29
+    /**
30
+     * @var string
31
+     */
32
+    protected $id;
33 33
 
34
-	/**
35
-	 * @var float
36
-	 */
37
-	protected $start;
34
+    /**
35
+     * @var float
36
+     */
37
+    protected $start;
38 38
 
39
-	/**
40
-	 * @var float
41
-	 */
42
-	protected $end;
39
+    /**
40
+     * @var float
41
+     */
42
+    protected $end;
43 43
 
44
-	/**
45
-	 * @var string
46
-	 */
47
-	protected $description;
44
+    /**
45
+     * @var string
46
+     */
47
+    protected $description;
48 48
 
49
-	/**
50
-	 * @param string $id
51
-	 * @param string $description
52
-	 * @param float $start
53
-	 */
54
-	public function __construct($id, $description, $start) {
55
-		$this->id = $id;
56
-		$this->description = $description;
57
-		$this->start = $start;
58
-	}
49
+    /**
50
+     * @param string $id
51
+     * @param string $description
52
+     * @param float $start
53
+     */
54
+    public function __construct($id, $description, $start) {
55
+        $this->id = $id;
56
+        $this->description = $description;
57
+        $this->start = $start;
58
+    }
59 59
 
60
-	/**
61
-	 * @param float $time
62
-	 */
63
-	public function end($time) {
64
-		$this->end = $time;
65
-	}
60
+    /**
61
+     * @param float $time
62
+     */
63
+    public function end($time) {
64
+        $this->end = $time;
65
+    }
66 66
 
67
-	/**
68
-	 * @return float
69
-	 */
70
-	public function getStart() {
71
-		return $this->start;
72
-	}
67
+    /**
68
+     * @return float
69
+     */
70
+    public function getStart() {
71
+        return $this->start;
72
+    }
73 73
 
74
-	/**
75
-	 * @return string
76
-	 */
77
-	public function getId() {
78
-		return $this->id;
79
-	}
74
+    /**
75
+     * @return string
76
+     */
77
+    public function getId() {
78
+        return $this->id;
79
+    }
80 80
 
81
-	/**
82
-	 * @return string
83
-	 */
84
-	public function getDescription() {
85
-		return $this->description;
86
-	}
81
+    /**
82
+     * @return string
83
+     */
84
+    public function getDescription() {
85
+        return $this->description;
86
+    }
87 87
 
88
-	/**
89
-	 * @return float
90
-	 */
91
-	public function getEnd() {
92
-		return $this->end;
93
-	}
88
+    /**
89
+     * @return float
90
+     */
91
+    public function getEnd() {
92
+        return $this->end;
93
+    }
94 94
 
95
-	/**
96
-	 * @return float
97
-	 */
98
-	public function getDuration() {
99
-		if (!$this->end) {
100
-			$this->end = microtime(true);
101
-		}
102
-		return $this->end - $this->start;
103
-	}
95
+    /**
96
+     * @return float
97
+     */
98
+    public function getDuration() {
99
+        if (!$this->end) {
100
+            $this->end = microtime(true);
101
+        }
102
+        return $this->end - $this->start;
103
+    }
104 104
 }
Please login to merge, or discard this patch.
lib/private/Tagging/TagMapper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 	* @return array An array of Tag objects.
51 51
 	*/
52 52
 	public function loadTags($owners, $type) {
53
-		if(!is_array($owners)) {
53
+		if (!is_array($owners)) {
54 54
 			$owners = array($owners);
55 55
 		}
56 56
 
57
-		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
58
-			. 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`';
57
+		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `'.$this->getTableName().'` '
58
+			. 'WHERE `uid` IN ('.str_repeat('?,', count($owners) - 1).'?) AND `type` = ? ORDER BY `category`';
59 59
 		return $this->findEntities($sql, array_merge($owners, array($type)));
60 60
 	}
61 61
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	* @return bool
67 67
 	*/
68 68
 	public function tagExists($tag) {
69
-		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
69
+		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `'.$this->getTableName().'` '
70 70
 			. 'WHERE `uid` = ? AND `type` = ? AND `category` = ?';
71 71
 		try {
72 72
 			$this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName()));
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
  */
34 34
 class TagMapper extends Mapper {
35 35
 
36
-	/**
37
-	* Constructor.
38
-	*
39
-	* @param IDBConnection $db Instance of the Db abstraction layer.
40
-	*/
41
-	public function __construct(IDBConnection $db) {
42
-		parent::__construct($db, 'vcategory', Tag::class);
43
-	}
36
+    /**
37
+     * Constructor.
38
+     *
39
+     * @param IDBConnection $db Instance of the Db abstraction layer.
40
+     */
41
+    public function __construct(IDBConnection $db) {
42
+        parent::__construct($db, 'vcategory', Tag::class);
43
+    }
44 44
 
45
-	/**
46
-	* Load tags from the database.
47
-	*
48
-	* @param array|string $owners The user(s) whose tags we are going to load.
49
-	* @param string $type The type of item for which we are loading tags.
50
-	* @return array An array of Tag objects.
51
-	*/
52
-	public function loadTags($owners, $type) {
53
-		if(!is_array($owners)) {
54
-			$owners = array($owners);
55
-		}
45
+    /**
46
+     * Load tags from the database.
47
+     *
48
+     * @param array|string $owners The user(s) whose tags we are going to load.
49
+     * @param string $type The type of item for which we are loading tags.
50
+     * @return array An array of Tag objects.
51
+     */
52
+    public function loadTags($owners, $type) {
53
+        if(!is_array($owners)) {
54
+            $owners = array($owners);
55
+        }
56 56
 
57
-		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
58
-			. 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`';
59
-		return $this->findEntities($sql, array_merge($owners, array($type)));
60
-	}
57
+        $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
58
+            . 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`';
59
+        return $this->findEntities($sql, array_merge($owners, array($type)));
60
+    }
61 61
 
62
-	/**
63
-	* Check if a given Tag object already exists in the database.
64
-	*
65
-	* @param Tag $tag The tag to look for in the database.
66
-	* @return bool
67
-	*/
68
-	public function tagExists($tag) {
69
-		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
70
-			. 'WHERE `uid` = ? AND `type` = ? AND `category` = ?';
71
-		try {
72
-			$this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName()));
73
-		} catch (DoesNotExistException $e) {
74
-			return false;
75
-		}
76
-		return true;
77
-	}
62
+    /**
63
+     * Check if a given Tag object already exists in the database.
64
+     *
65
+     * @param Tag $tag The tag to look for in the database.
66
+     * @return bool
67
+     */
68
+    public function tagExists($tag) {
69
+        $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
70
+            . 'WHERE `uid` = ? AND `type` = ? AND `category` = ?';
71
+        try {
72
+            $this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName()));
73
+        } catch (DoesNotExistException $e) {
74
+            return false;
75
+        }
76
+        return true;
77
+    }
78 78
 }
79 79
 
Please login to merge, or discard this patch.
lib/private/Tagging/Tag.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -37,54 +37,54 @@
 block discarded – undo
37 37
  */
38 38
 class Tag extends Entity {
39 39
 
40
-	protected $owner;
41
-	protected $type;
42
-	protected $name;
40
+    protected $owner;
41
+    protected $type;
42
+    protected $name;
43 43
 
44
-	/**
45
-	* Constructor.
46
-	*
47
-	* @param string $owner The tag's owner
48
-	* @param string $type The type of item this tag is used for
49
-	* @param string $name The tag's name
50
-	*/
51
-	public function __construct($owner = null, $type = null, $name = null) {
52
-		$this->setOwner($owner);
53
-		$this->setType($type);
54
-		$this->setName($name);
55
-	}
44
+    /**
45
+     * Constructor.
46
+     *
47
+     * @param string $owner The tag's owner
48
+     * @param string $type The type of item this tag is used for
49
+     * @param string $name The tag's name
50
+     */
51
+    public function __construct($owner = null, $type = null, $name = null) {
52
+        $this->setOwner($owner);
53
+        $this->setType($type);
54
+        $this->setName($name);
55
+    }
56 56
 
57
-	/**
58
-	 * Transform a database columnname to a property
59
-	 *
60
-	 * @param string $columnName the name of the column
61
-	 * @return string the property name
62
-	 * @todo migrate existing database columns to the correct names
63
-	 * to be able to drop this direct mapping
64
-	 */
65
-	public function columnToProperty($columnName){
66
-		if ($columnName === 'category') {
67
-		    return 'name';
68
-		} elseif ($columnName === 'uid') {
69
-		    return 'owner';
70
-		} else {
71
-		    return parent::columnToProperty($columnName);
72
-		}
73
-	}
57
+    /**
58
+     * Transform a database columnname to a property
59
+     *
60
+     * @param string $columnName the name of the column
61
+     * @return string the property name
62
+     * @todo migrate existing database columns to the correct names
63
+     * to be able to drop this direct mapping
64
+     */
65
+    public function columnToProperty($columnName){
66
+        if ($columnName === 'category') {
67
+            return 'name';
68
+        } elseif ($columnName === 'uid') {
69
+            return 'owner';
70
+        } else {
71
+            return parent::columnToProperty($columnName);
72
+        }
73
+    }
74 74
 
75
-	/**
76
-	 * Transform a property to a database column name
77
-	 *
78
-	 * @param string $property the name of the property
79
-	 * @return string the column name
80
-	 */
81
-	public function propertyToColumn($property){
82
-		if ($property === 'name') {
83
-		    return 'category';
84
-		} elseif ($property === 'owner') {
85
-		    return 'uid';
86
-		} else {
87
-		    return parent::propertyToColumn($property);
88
-		}
89
-	}
75
+    /**
76
+     * Transform a property to a database column name
77
+     *
78
+     * @param string $property the name of the property
79
+     * @return string the column name
80
+     */
81
+    public function propertyToColumn($property){
82
+        if ($property === 'name') {
83
+            return 'category';
84
+        } elseif ($property === 'owner') {
85
+            return 'uid';
86
+        } else {
87
+            return parent::propertyToColumn($property);
88
+        }
89
+    }
90 90
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @todo migrate existing database columns to the correct names
63 63
 	 * to be able to drop this direct mapping
64 64
 	 */
65
-	public function columnToProperty($columnName){
65
+	public function columnToProperty($columnName) {
66 66
 		if ($columnName === 'category') {
67 67
 		    return 'name';
68 68
 		} elseif ($columnName === 'uid') {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param string $property the name of the property
79 79
 	 * @return string the column name
80 80
 	 */
81
-	public function propertyToColumn($property){
81
+	public function propertyToColumn($property) {
82 82
 		if ($property === 'name') {
83 83
 		    return 'category';
84 84
 		} elseif ($property === 'owner') {
Please login to merge, or discard this patch.
lib/private/TagManager.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -40,53 +40,53 @@
 block discarded – undo
40 40
 
41 41
 class TagManager implements \OCP\ITagManager {
42 42
 
43
-	/**
44
-	 * User session
45
-	 *
46
-	 * @var \OCP\IUserSession
47
-	 */
48
-	private $userSession;
43
+    /**
44
+     * User session
45
+     *
46
+     * @var \OCP\IUserSession
47
+     */
48
+    private $userSession;
49 49
 
50
-	/**
51
-	 * TagMapper
52
-	 *
53
-	 * @var TagMapper
54
-	 */
55
-	private $mapper;
50
+    /**
51
+     * TagMapper
52
+     *
53
+     * @var TagMapper
54
+     */
55
+    private $mapper;
56 56
 
57
-	/**
58
-	* Constructor.
59
-	*
60
-	* @param TagMapper $mapper Instance of the TagMapper abstraction layer.
61
-	* @param \OCP\IUserSession $userSession the user session
62
-	*/
63
-	public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) {
64
-		$this->mapper = $mapper;
65
-		$this->userSession = $userSession;
57
+    /**
58
+     * Constructor.
59
+     *
60
+     * @param TagMapper $mapper Instance of the TagMapper abstraction layer.
61
+     * @param \OCP\IUserSession $userSession the user session
62
+     */
63
+    public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) {
64
+        $this->mapper = $mapper;
65
+        $this->userSession = $userSession;
66 66
 
67
-	}
67
+    }
68 68
 
69
-	/**
70
-	* Create a new \OCP\ITags instance and load tags from db.
71
-	*
72
-	* @see \OCP\ITags
73
-	* @param string $type The type identifier e.g. 'contact' or 'event'.
74
-	* @param array $defaultTags An array of default tags to be used if none are stored.
75
-	* @param boolean $includeShared Whether to include tags for items shared with this user by others.
76
-	* @param string $userId user for which to retrieve the tags, defaults to the currently
77
-	* logged in user
78
-	* @return \OCP\ITags
79
-	*/
80
-	public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) {
81
-		if (is_null($userId)) {
82
-			$user = $this->userSession->getUser();
83
-			if ($user === null) {
84
-				// nothing we can do without a user
85
-				return null;
86
-			}
87
-			$userId = $this->userSession->getUser()->getUId();
88
-		}
89
-		return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared);
90
-	}
69
+    /**
70
+     * Create a new \OCP\ITags instance and load tags from db.
71
+     *
72
+     * @see \OCP\ITags
73
+     * @param string $type The type identifier e.g. 'contact' or 'event'.
74
+     * @param array $defaultTags An array of default tags to be used if none are stored.
75
+     * @param boolean $includeShared Whether to include tags for items shared with this user by others.
76
+     * @param string $userId user for which to retrieve the tags, defaults to the currently
77
+     * logged in user
78
+     * @return \OCP\ITags
79
+     */
80
+    public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) {
81
+        if (is_null($userId)) {
82
+            $user = $this->userSession->getUser();
83
+            if ($user === null) {
84
+                // nothing we can do without a user
85
+                return null;
86
+            }
87
+            $userId = $this->userSession->getUser()->getUId();
88
+        }
89
+        return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared);
90
+    }
91 91
 
92 92
 }
Please login to merge, or discard this patch.
lib/private/ContactsManager.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -27,164 +27,164 @@
 block discarded – undo
27 27
 
28 28
 namespace OC {
29 29
 
30
-	class ContactsManager implements \OCP\Contacts\IManager {
31
-
32
-		/**
33
-		 * This function is used to search and find contacts within the users address books.
34
-		 * In case $pattern is empty all contacts will be returned.
35
-		 *
36
-		 * @param string $pattern which should match within the $searchProperties
37
-		 * @param array $searchProperties defines the properties within the query pattern should match
38
-		 * @param array $options - for future use. One should always have options!
39
-		 * @return array an array of contacts which are arrays of key-value-pairs
40
-		 */
41
-		public function search($pattern, $searchProperties = array(), $options = array()) {
42
-			$this->loadAddressBooks();
43
-			$result = array();
44
-			foreach($this->addressBooks as $addressBook) {
45
-				$r = $addressBook->search($pattern, $searchProperties, $options);
46
-				$contacts = array();
47
-				foreach($r as $c){
48
-					$c['addressbook-key'] = $addressBook->getKey();
49
-					$contacts[] = $c;
50
-				}
51
-				$result = array_merge($result, $contacts);
52
-			}
53
-
54
-			return $result;
55
-		}
56
-
57
-		/**
58
-		 * This function can be used to delete the contact identified by the given id
59
-		 *
60
-		 * @param object $id the unique identifier to a contact
61
-		 * @param string $addressBookKey identifier of the address book in which the contact shall be deleted
62
-		 * @return bool successful or not
63
-		 */
64
-		public function delete($id, $addressBookKey) {
65
-			$addressBook = $this->getAddressBook($addressBookKey);
66
-			if (!$addressBook) {
67
-				return null;
68
-			}
69
-
70
-			if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) {
71
-				return $addressBook->delete($id);
72
-			}
73
-
74
-			return null;
75
-		}
76
-
77
-		/**
78
-		 * This function is used to create a new contact if 'id' is not given or not present.
79
-		 * Otherwise the contact will be updated by replacing the entire data set.
80
-		 *
81
-		 * @param array $properties this array if key-value-pairs defines a contact
82
-		 * @param string $addressBookKey identifier of the address book in which the contact shall be created or updated
83
-		 * @return array representing the contact just created or updated
84
-		 */
85
-		public function createOrUpdate($properties, $addressBookKey) {
86
-			$addressBook = $this->getAddressBook($addressBookKey);
87
-			if (!$addressBook) {
88
-				return null;
89
-			}
90
-
91
-			if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) {
92
-				return $addressBook->createOrUpdate($properties);
93
-			}
94
-
95
-			return null;
96
-		}
97
-
98
-		/**
99
-		 * Check if contacts are available (e.g. contacts app enabled)
100
-		 *
101
-		 * @return bool true if enabled, false if not
102
-		 */
103
-		public function isEnabled() {
104
-			return !empty($this->addressBooks) || !empty($this->addressBookLoaders);
105
-		}
106
-
107
-		/**
108
-		 * @param \OCP\IAddressBook $addressBook
109
-		 */
110
-		public function registerAddressBook(\OCP\IAddressBook $addressBook) {
111
-			$this->addressBooks[$addressBook->getKey()] = $addressBook;
112
-		}
113
-
114
-		/**
115
-		 * @param \OCP\IAddressBook $addressBook
116
-		 */
117
-		public function unregisterAddressBook(\OCP\IAddressBook $addressBook) {
118
-			unset($this->addressBooks[$addressBook->getKey()]);
119
-		}
120
-
121
-		/**
122
-		 * @return array
123
-		 */
124
-		public function getAddressBooks() {
125
-			$this->loadAddressBooks();
126
-			$result = array();
127
-			foreach($this->addressBooks as $addressBook) {
128
-				$result[$addressBook->getKey()] = $addressBook->getDisplayName();
129
-			}
130
-
131
-			return $result;
132
-		}
133
-
134
-		/**
135
-		 * removes all registered address book instances
136
-		 */
137
-		public function clear() {
138
-			$this->addressBooks = array();
139
-			$this->addressBookLoaders = array();
140
-		}
141
-
142
-		/**
143
-		 * @var \OCP\IAddressBook[] which holds all registered address books
144
-		 */
145
-		private $addressBooks = array();
146
-
147
-		/**
148
-		 * @var \Closure[] to call to load/register address books
149
-		 */
150
-		private $addressBookLoaders = array();
151
-
152
-		/**
153
-		 * In order to improve lazy loading a closure can be registered which will be called in case
154
-		 * address books are actually requested
155
-		 *
156
-		 * @param \Closure $callable
157
-		 */
158
-		public function register(\Closure $callable)
159
-		{
160
-			$this->addressBookLoaders[] = $callable;
161
-		}
162
-
163
-		/**
164
-		 * Get (and load when needed) the address book for $key
165
-		 *
166
-		 * @param string $addressBookKey
167
-		 * @return \OCP\IAddressBook
168
-		 */
169
-		protected function getAddressBook($addressBookKey)
170
-		{
171
-			$this->loadAddressBooks();
172
-			if (!array_key_exists($addressBookKey, $this->addressBooks)) {
173
-				return null;
174
-			}
175
-
176
-			return $this->addressBooks[$addressBookKey];
177
-		}
178
-
179
-		/**
180
-		 * Load all address books registered with 'register'
181
-		 */
182
-		protected function loadAddressBooks()
183
-		{
184
-			foreach($this->addressBookLoaders as $callable) {
185
-				$callable($this);
186
-			}
187
-			$this->addressBookLoaders = array();
188
-		}
189
-	}
30
+    class ContactsManager implements \OCP\Contacts\IManager {
31
+
32
+        /**
33
+         * This function is used to search and find contacts within the users address books.
34
+         * In case $pattern is empty all contacts will be returned.
35
+         *
36
+         * @param string $pattern which should match within the $searchProperties
37
+         * @param array $searchProperties defines the properties within the query pattern should match
38
+         * @param array $options - for future use. One should always have options!
39
+         * @return array an array of contacts which are arrays of key-value-pairs
40
+         */
41
+        public function search($pattern, $searchProperties = array(), $options = array()) {
42
+            $this->loadAddressBooks();
43
+            $result = array();
44
+            foreach($this->addressBooks as $addressBook) {
45
+                $r = $addressBook->search($pattern, $searchProperties, $options);
46
+                $contacts = array();
47
+                foreach($r as $c){
48
+                    $c['addressbook-key'] = $addressBook->getKey();
49
+                    $contacts[] = $c;
50
+                }
51
+                $result = array_merge($result, $contacts);
52
+            }
53
+
54
+            return $result;
55
+        }
56
+
57
+        /**
58
+         * This function can be used to delete the contact identified by the given id
59
+         *
60
+         * @param object $id the unique identifier to a contact
61
+         * @param string $addressBookKey identifier of the address book in which the contact shall be deleted
62
+         * @return bool successful or not
63
+         */
64
+        public function delete($id, $addressBookKey) {
65
+            $addressBook = $this->getAddressBook($addressBookKey);
66
+            if (!$addressBook) {
67
+                return null;
68
+            }
69
+
70
+            if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) {
71
+                return $addressBook->delete($id);
72
+            }
73
+
74
+            return null;
75
+        }
76
+
77
+        /**
78
+         * This function is used to create a new contact if 'id' is not given or not present.
79
+         * Otherwise the contact will be updated by replacing the entire data set.
80
+         *
81
+         * @param array $properties this array if key-value-pairs defines a contact
82
+         * @param string $addressBookKey identifier of the address book in which the contact shall be created or updated
83
+         * @return array representing the contact just created or updated
84
+         */
85
+        public function createOrUpdate($properties, $addressBookKey) {
86
+            $addressBook = $this->getAddressBook($addressBookKey);
87
+            if (!$addressBook) {
88
+                return null;
89
+            }
90
+
91
+            if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) {
92
+                return $addressBook->createOrUpdate($properties);
93
+            }
94
+
95
+            return null;
96
+        }
97
+
98
+        /**
99
+         * Check if contacts are available (e.g. contacts app enabled)
100
+         *
101
+         * @return bool true if enabled, false if not
102
+         */
103
+        public function isEnabled() {
104
+            return !empty($this->addressBooks) || !empty($this->addressBookLoaders);
105
+        }
106
+
107
+        /**
108
+         * @param \OCP\IAddressBook $addressBook
109
+         */
110
+        public function registerAddressBook(\OCP\IAddressBook $addressBook) {
111
+            $this->addressBooks[$addressBook->getKey()] = $addressBook;
112
+        }
113
+
114
+        /**
115
+         * @param \OCP\IAddressBook $addressBook
116
+         */
117
+        public function unregisterAddressBook(\OCP\IAddressBook $addressBook) {
118
+            unset($this->addressBooks[$addressBook->getKey()]);
119
+        }
120
+
121
+        /**
122
+         * @return array
123
+         */
124
+        public function getAddressBooks() {
125
+            $this->loadAddressBooks();
126
+            $result = array();
127
+            foreach($this->addressBooks as $addressBook) {
128
+                $result[$addressBook->getKey()] = $addressBook->getDisplayName();
129
+            }
130
+
131
+            return $result;
132
+        }
133
+
134
+        /**
135
+         * removes all registered address book instances
136
+         */
137
+        public function clear() {
138
+            $this->addressBooks = array();
139
+            $this->addressBookLoaders = array();
140
+        }
141
+
142
+        /**
143
+         * @var \OCP\IAddressBook[] which holds all registered address books
144
+         */
145
+        private $addressBooks = array();
146
+
147
+        /**
148
+         * @var \Closure[] to call to load/register address books
149
+         */
150
+        private $addressBookLoaders = array();
151
+
152
+        /**
153
+         * In order to improve lazy loading a closure can be registered which will be called in case
154
+         * address books are actually requested
155
+         *
156
+         * @param \Closure $callable
157
+         */
158
+        public function register(\Closure $callable)
159
+        {
160
+            $this->addressBookLoaders[] = $callable;
161
+        }
162
+
163
+        /**
164
+         * Get (and load when needed) the address book for $key
165
+         *
166
+         * @param string $addressBookKey
167
+         * @return \OCP\IAddressBook
168
+         */
169
+        protected function getAddressBook($addressBookKey)
170
+        {
171
+            $this->loadAddressBooks();
172
+            if (!array_key_exists($addressBookKey, $this->addressBooks)) {
173
+                return null;
174
+            }
175
+
176
+            return $this->addressBooks[$addressBookKey];
177
+        }
178
+
179
+        /**
180
+         * Load all address books registered with 'register'
181
+         */
182
+        protected function loadAddressBooks()
183
+        {
184
+            foreach($this->addressBookLoaders as $callable) {
185
+                $callable($this);
186
+            }
187
+            $this->addressBookLoaders = array();
188
+        }
189
+    }
190 190
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 		public function search($pattern, $searchProperties = array(), $options = array()) {
42 42
 			$this->loadAddressBooks();
43 43
 			$result = array();
44
-			foreach($this->addressBooks as $addressBook) {
44
+			foreach ($this->addressBooks as $addressBook) {
45 45
 				$r = $addressBook->search($pattern, $searchProperties, $options);
46 46
 				$contacts = array();
47
-				foreach($r as $c){
47
+				foreach ($r as $c) {
48 48
 					$c['addressbook-key'] = $addressBook->getKey();
49 49
 					$contacts[] = $c;
50 50
 				}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		public function getAddressBooks() {
125 125
 			$this->loadAddressBooks();
126 126
 			$result = array();
127
-			foreach($this->addressBooks as $addressBook) {
127
+			foreach ($this->addressBooks as $addressBook) {
128 128
 				$result[$addressBook->getKey()] = $addressBook->getDisplayName();
129 129
 			}
130 130
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		 */
182 182
 		protected function loadAddressBooks()
183 183
 		{
184
-			foreach($this->addressBookLoaders as $callable) {
184
+			foreach ($this->addressBookLoaders as $callable) {
185 185
 				$callable($this);
186 186
 			}
187 187
 			$this->addressBookLoaders = array();
Please login to merge, or discard this patch.
lib/private/Archive/Archive.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@
 block discarded – undo
134 134
 				}
135 135
 				if(is_dir($source.'/'.$file)) {
136 136
 					$this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
-				}else{
137
+				} else{
138 138
 					$this->addFile($path.'/'.$file, $source.'/'.$file);
139 139
 				}
140 140
 			}
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -33,111 +33,111 @@
 block discarded – undo
33 33
 namespace OC\Archive;
34 34
 
35 35
 abstract class Archive {
36
-	/**
37
-	 * @param $source
38
-	 */
39
-	public abstract function __construct($source);
40
-	/**
41
-	 * add an empty folder to the archive
42
-	 * @param string $path
43
-	 * @return bool
44
-	 */
45
-	public abstract function addFolder($path);
46
-	/**
47
-	 * add a file to the archive
48
-	 * @param string $path
49
-	 * @param string $source either a local file or string data
50
-	 * @return bool
51
-	 */
52
-	public abstract function addFile($path, $source='');
53
-	/**
54
-	 * rename a file or folder in the archive
55
-	 * @param string $source
56
-	 * @param string $dest
57
-	 * @return bool
58
-	 */
59
-	public abstract function rename($source, $dest);
60
-	/**
61
-	 * get the uncompressed size of a file in the archive
62
-	 * @param string $path
63
-	 * @return int
64
-	 */
65
-	public abstract function filesize($path);
66
-	/**
67
-	 * get the last modified time of a file in the archive
68
-	 * @param string $path
69
-	 * @return int
70
-	 */
71
-	public abstract function mtime($path);
72
-	/**
73
-	 * get the files in a folder
74
-	 * @param string $path
75
-	 * @return array
76
-	 */
77
-	public abstract function getFolder($path);
78
-	/**
79
-	 * get all files in the archive
80
-	 * @return array
81
-	 */
82
-	public abstract function getFiles();
83
-	/**
84
-	 * get the content of a file
85
-	 * @param string $path
86
-	 * @return string
87
-	 */
88
-	public abstract function getFile($path);
89
-	/**
90
-	 * extract a single file from the archive
91
-	 * @param string $path
92
-	 * @param string $dest
93
-	 * @return bool
94
-	 */
95
-	public abstract function extractFile($path, $dest);
96
-	/**
97
-	 * extract the archive
98
-	 * @param string $dest
99
-	 * @return bool
100
-	 */
101
-	public abstract function extract($dest);
102
-	/**
103
-	 * check if a file or folder exists in the archive
104
-	 * @param string $path
105
-	 * @return bool
106
-	 */
107
-	public abstract function fileExists($path);
108
-	/**
109
-	 * remove a file or folder from the archive
110
-	 * @param string $path
111
-	 * @return bool
112
-	 */
113
-	public abstract function remove($path);
114
-	/**
115
-	 * get a file handler
116
-	 * @param string $path
117
-	 * @param string $mode
118
-	 * @return resource
119
-	 */
120
-	public abstract function getStream($path, $mode);
121
-	/**
122
-	 * add a folder and all its content
123
-	 * @param string $path
124
-	 * @param string $source
125
-	 * @return boolean|null
126
-	 */
127
-	public function addRecursive($path, $source) {
128
-		$dh = opendir($source);
129
-		if(is_resource($dh)) {
130
-			$this->addFolder($path);
131
-			while (($file = readdir($dh)) !== false) {
132
-				if($file === '.' || $file === '..') {
133
-					continue;
134
-				}
135
-				if(is_dir($source.'/'.$file)) {
136
-					$this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
-				}else{
138
-					$this->addFile($path.'/'.$file, $source.'/'.$file);
139
-				}
140
-			}
141
-		}
142
-	}
36
+    /**
37
+     * @param $source
38
+     */
39
+    public abstract function __construct($source);
40
+    /**
41
+     * add an empty folder to the archive
42
+     * @param string $path
43
+     * @return bool
44
+     */
45
+    public abstract function addFolder($path);
46
+    /**
47
+     * add a file to the archive
48
+     * @param string $path
49
+     * @param string $source either a local file or string data
50
+     * @return bool
51
+     */
52
+    public abstract function addFile($path, $source='');
53
+    /**
54
+     * rename a file or folder in the archive
55
+     * @param string $source
56
+     * @param string $dest
57
+     * @return bool
58
+     */
59
+    public abstract function rename($source, $dest);
60
+    /**
61
+     * get the uncompressed size of a file in the archive
62
+     * @param string $path
63
+     * @return int
64
+     */
65
+    public abstract function filesize($path);
66
+    /**
67
+     * get the last modified time of a file in the archive
68
+     * @param string $path
69
+     * @return int
70
+     */
71
+    public abstract function mtime($path);
72
+    /**
73
+     * get the files in a folder
74
+     * @param string $path
75
+     * @return array
76
+     */
77
+    public abstract function getFolder($path);
78
+    /**
79
+     * get all files in the archive
80
+     * @return array
81
+     */
82
+    public abstract function getFiles();
83
+    /**
84
+     * get the content of a file
85
+     * @param string $path
86
+     * @return string
87
+     */
88
+    public abstract function getFile($path);
89
+    /**
90
+     * extract a single file from the archive
91
+     * @param string $path
92
+     * @param string $dest
93
+     * @return bool
94
+     */
95
+    public abstract function extractFile($path, $dest);
96
+    /**
97
+     * extract the archive
98
+     * @param string $dest
99
+     * @return bool
100
+     */
101
+    public abstract function extract($dest);
102
+    /**
103
+     * check if a file or folder exists in the archive
104
+     * @param string $path
105
+     * @return bool
106
+     */
107
+    public abstract function fileExists($path);
108
+    /**
109
+     * remove a file or folder from the archive
110
+     * @param string $path
111
+     * @return bool
112
+     */
113
+    public abstract function remove($path);
114
+    /**
115
+     * get a file handler
116
+     * @param string $path
117
+     * @param string $mode
118
+     * @return resource
119
+     */
120
+    public abstract function getStream($path, $mode);
121
+    /**
122
+     * add a folder and all its content
123
+     * @param string $path
124
+     * @param string $source
125
+     * @return boolean|null
126
+     */
127
+    public function addRecursive($path, $source) {
128
+        $dh = opendir($source);
129
+        if(is_resource($dh)) {
130
+            $this->addFolder($path);
131
+            while (($file = readdir($dh)) !== false) {
132
+                if($file === '.' || $file === '..') {
133
+                    continue;
134
+                }
135
+                if(is_dir($source.'/'.$file)) {
136
+                    $this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
+                }else{
138
+                    $this->addFile($path.'/'.$file, $source.'/'.$file);
139
+                }
140
+            }
141
+        }
142
+    }
143 143
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param string $source either a local file or string data
50 50
 	 * @return bool
51 51
 	 */
52
-	public abstract function addFile($path, $source='');
52
+	public abstract function addFile($path, $source = '');
53 53
 	/**
54 54
 	 * rename a file or folder in the archive
55 55
 	 * @param string $source
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function addRecursive($path, $source) {
128 128
 		$dh = opendir($source);
129
-		if(is_resource($dh)) {
129
+		if (is_resource($dh)) {
130 130
 			$this->addFolder($path);
131 131
 			while (($file = readdir($dh)) !== false) {
132
-				if($file === '.' || $file === '..') {
132
+				if ($file === '.' || $file === '..') {
133 133
 					continue;
134 134
 				}
135
-				if(is_dir($source.'/'.$file)) {
135
+				if (is_dir($source.'/'.$file)) {
136 136
 					$this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
-				}else{
137
+				} else {
138 138
 					$this->addFile($path.'/'.$file, $source.'/'.$file);
139 139
 				}
140 140
 			}
Please login to merge, or discard this patch.
lib/private/NaturalSort_DefaultCollator.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
 namespace OC;
26 26
 
27 27
 class NaturalSort_DefaultCollator {
28
-	public function compare($a, $b) {
29
-		$result = strcasecmp($a, $b);
30
-		if ($result === 0) {
31
-			if ($a === $b) {
32
-				return 0;
33
-			}
34
-			return ($a > $b) ? -1 : 1;
35
-		}
36
-		return ($result < 0) ? -1 : 1;
37
-	}
28
+    public function compare($a, $b) {
29
+        $result = strcasecmp($a, $b);
30
+        if ($result === 0) {
31
+            if ($a === $b) {
32
+                return 0;
33
+            }
34
+            return ($a > $b) ? -1 : 1;
35
+        }
36
+        return ($result < 0) ? -1 : 1;
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 			parent::__construct( 'core', 'layout.user' );
62 62
 			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63 63
 				$this->assign('bodyid', 'body-settings');
64
-			}else{
64
+			} else{
65 65
 				$this->assign('bodyid', 'body-user');
66 66
 			}
67 67
 
Please login to merge, or discard this patch.
Indentation   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -45,285 +45,285 @@
 block discarded – undo
45 45
 
46 46
 class TemplateLayout extends \OC_Template {
47 47
 
48
-	private static $versionHash = '';
49
-
50
-	/**
51
-	 * @var \OCP\IConfig
52
-	 */
53
-	private $config;
54
-
55
-	/**
56
-	 * @param string $renderAs
57
-	 * @param string $appId application id
58
-	 */
59
-	public function __construct( $renderAs, $appId = '' ) {
60
-
61
-		// yes - should be injected ....
62
-		$this->config = \OC::$server->getConfig();
63
-
64
-
65
-		// Decide which page we show
66
-		if($renderAs == 'user') {
67
-			parent::__construct( 'core', 'layout.user' );
68
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
69
-				$this->assign('bodyid', 'body-settings');
70
-			}else{
71
-				$this->assign('bodyid', 'body-user');
72
-			}
73
-
74
-			// Code integrity notification
75
-			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
76
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
77
-				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
78
-			}
79
-
80
-			// Add navigation entry
81
-			$this->assign( 'application', '');
82
-			$this->assign( 'appid', $appId );
83
-			$navigation = \OC::$server->getNavigationManager()->getAll();
84
-			$this->assign( 'navigation', $navigation);
85
-			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
86
-			$this->assign( 'settingsnavigation', $settingsNavigation);
87
-			foreach($navigation as $entry) {
88
-				if ($entry['active']) {
89
-					$this->assign( 'application', $entry['name'] );
90
-					break;
91
-				}
92
-			}
93
-
94
-			foreach($settingsNavigation as $entry) {
95
-				if ($entry['active']) {
96
-					$this->assign( 'application', $entry['name'] );
97
-					break;
98
-				}
99
-			}
100
-			$userDisplayName = \OC_User::getDisplayName();
101
-			$this->assign('user_displayname', $userDisplayName);
102
-			$this->assign('user_uid', \OC_User::getUser());
103
-
104
-			if (\OC_User::getUser() === false) {
105
-				$this->assign('userAvatarSet', false);
106
-			} else {
107
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
108
-				$this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
109
-			}
110
-
111
-			// check if app menu icons should be inverted
112
-			try {
113
-				/** @var \OCA\Theming\Util $util */
114
-				$util = \OC::$server->query(\OCA\Theming\Util::class);
115
-				$this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
116
-			} catch (\OCP\AppFramework\QueryException $e) {
117
-				$this->assign('themingInvertMenu', false);
118
-			}
119
-
120
-		} else if ($renderAs == 'error') {
121
-			parent::__construct('core', 'layout.guest', '', false);
122
-			$this->assign('bodyid', 'body-login');
123
-		} else if ($renderAs == 'guest') {
124
-			parent::__construct('core', 'layout.guest');
125
-			$this->assign('bodyid', 'body-login');
126
-		} else if ($renderAs == 'public') {
127
-			parent::__construct('core', 'layout.public');
128
-			$this->assign( 'appid', $appId );
129
-			$this->assign('bodyid', 'body-public');
130
-		} else {
131
-			parent::__construct('core', 'layout.base');
132
-
133
-		}
134
-		// Send the language to our layouts
135
-		$lang = \OC::$server->getL10NFactory()->findLanguage();
136
-		$lang = str_replace('_', '-', $lang);
137
-		$this->assign('language', $lang);
138
-
139
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
140
-			if (empty(self::$versionHash)) {
141
-				$v = \OC_App::getAppVersions();
142
-				$v['core'] = implode('.', \OCP\Util::getVersion());
143
-				self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
144
-			}
145
-		} else {
146
-			self::$versionHash = md5('not installed');
147
-		}
148
-
149
-		// Add the js files
150
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
151
-		$this->assign('jsfiles', array());
152
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
153
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
154
-				$jsConfigHelper = new JSConfigHelper(
155
-					\OC::$server->getL10N('lib'),
156
-					\OC::$server->query(Defaults::class),
157
-					\OC::$server->getAppManager(),
158
-					\OC::$server->getSession(),
159
-					\OC::$server->getUserSession()->getUser(),
160
-					$this->config,
161
-					\OC::$server->getGroupManager(),
162
-					\OC::$server->getIniWrapper(),
163
-					\OC::$server->getURLGenerator(),
164
-					\OC::$server->getCapabilitiesManager()
165
-				);
166
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
167
-			} else {
168
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
169
-			}
170
-		}
171
-		foreach($jsFiles as $info) {
172
-			$web = $info[1];
173
-			$file = $info[2];
174
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
175
-		}
176
-
177
-		try {
178
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
179
-		} catch (\Exception $e) {
180
-			$pathInfo = '';
181
-		}
182
-
183
-		// Do not initialise scss appdata until we have a fully installed instance
184
-		// Do not load scss for update, errors, installation or login page
185
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
186
-			&& !\OCP\Util::needUpgrade()
187
-			&& $pathInfo !== ''
188
-			&& !preg_match('/^\/login/', $pathInfo)
189
-			&& $renderAs !== 'error' && $renderAs !== 'guest'
190
-		) {
191
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
192
-		} else {
193
-			// If we ignore the scss compiler,
194
-			// we need to load the guest css fallback
195
-			\OC_Util::addStyle('guest');
196
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
197
-		}
198
-
199
-		$this->assign('cssfiles', array());
200
-		$this->assign('printcssfiles', []);
201
-		$this->assign('versionHash', self::$versionHash);
202
-		foreach($cssFiles as $info) {
203
-			$web = $info[1];
204
-			$file = $info[2];
205
-
206
-			if (substr($file, -strlen('print.css')) === 'print.css') {
207
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
208
-			} else {
209
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file)  );
210
-			}
211
-		}
212
-	}
213
-
214
-	/**
215
-	 * @param string $path
216
- 	 * @param string $file
217
-	 * @return string
218
-	 */
219
-	protected function getVersionHashSuffix($path = false, $file = false) {
220
-		if ($this->config->getSystemValue('debug', false)) {
221
-			// allows chrome workspace mapping in debug mode
222
-			return "";
223
-		}
224
-		$themingSuffix = '';
225
-		$v = [];
226
-
227
-		if ($this->config->getSystemValue('installed', false)) {
228
-			if (\OC::$server->getAppManager()->isInstalled('theming')) {
229
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
230
-			}
231
-			$v = \OC_App::getAppVersions();
232
-		}
233
-
234
-		// Try the webroot path for a match
235
-		if ($path !== false && $path !== '') {
236
-			$appName = $this->getAppNamefromPath($path);
237
-			if(array_key_exists($appName, $v)) {
238
-				$appVersion = $v[$appName];
239
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
240
-			}
241
-		}
242
-		// fallback to the file path instead
243
-		if ($file !== false && $file !== '') {
244
-			$appName = $this->getAppNamefromPath($file);
245
-			if(array_key_exists($appName, $v)) {
246
-				$appVersion = $v[$appName];
247
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
248
-			}
249
-		}
250
-
251
-		return '?v=' . self::$versionHash . $themingSuffix;
252
-	}
253
-
254
-	/**
255
-	 * @param array $styles
256
-	 * @return array
257
-	 */
258
-	static public function findStylesheetFiles($styles, $compileScss = true) {
259
-		// Read the selected theme from the config file
260
-		$theme = \OC_Util::getTheme();
261
-
262
-		if($compileScss) {
263
-			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
264
-		} else {
265
-			$SCSSCacher = null;
266
-		}
267
-
268
-		$locator = new \OC\Template\CSSResourceLocator(
269
-			\OC::$server->getLogger(),
270
-			$theme,
271
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
272
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
273
-			$SCSSCacher
274
-		);
275
-		$locator->find($styles);
276
-		return $locator->getResources();
277
-	}
278
-
279
-	/**
280
-	 * @param string $path
281
-	 * @return string|boolean
282
-	 */
283
-	public function getAppNamefromPath($path) {
284
-		if ($path !== '' && is_string($path)) {
285
-			$pathParts = explode('/', $path);
286
-			if ($pathParts[0] === 'css') {
287
-				// This is a scss request
288
-				return $pathParts[1];
289
-			}
290
-			return end($pathParts);
291
-		}
292
-		return false;
293
-
294
-	}
295
-
296
-	/**
297
-	 * @param array $scripts
298
-	 * @return array
299
-	 */
300
-	static public function findJavascriptFiles($scripts) {
301
-		// Read the selected theme from the config file
302
-		$theme = \OC_Util::getTheme();
303
-
304
-		$locator = new \OC\Template\JSResourceLocator(
305
-			\OC::$server->getLogger(),
306
-			$theme,
307
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
308
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
309
-			\OC::$server->query(JSCombiner::class)
310
-			);
311
-		$locator->find($scripts);
312
-		return $locator->getResources();
313
-	}
314
-
315
-	/**
316
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
317
-	 * @param string $filePath Absolute path
318
-	 * @return string Relative path
319
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
320
-	 */
321
-	public static function convertToRelativePath($filePath) {
322
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
323
-		if(count($relativePath) !== 2) {
324
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
325
-		}
326
-
327
-		return $relativePath[1];
328
-	}
48
+    private static $versionHash = '';
49
+
50
+    /**
51
+     * @var \OCP\IConfig
52
+     */
53
+    private $config;
54
+
55
+    /**
56
+     * @param string $renderAs
57
+     * @param string $appId application id
58
+     */
59
+    public function __construct( $renderAs, $appId = '' ) {
60
+
61
+        // yes - should be injected ....
62
+        $this->config = \OC::$server->getConfig();
63
+
64
+
65
+        // Decide which page we show
66
+        if($renderAs == 'user') {
67
+            parent::__construct( 'core', 'layout.user' );
68
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
69
+                $this->assign('bodyid', 'body-settings');
70
+            }else{
71
+                $this->assign('bodyid', 'body-user');
72
+            }
73
+
74
+            // Code integrity notification
75
+            $integrityChecker = \OC::$server->getIntegrityCodeChecker();
76
+            if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
77
+                \OCP\Util::addScript('core', 'integritycheck-failed-notification');
78
+            }
79
+
80
+            // Add navigation entry
81
+            $this->assign( 'application', '');
82
+            $this->assign( 'appid', $appId );
83
+            $navigation = \OC::$server->getNavigationManager()->getAll();
84
+            $this->assign( 'navigation', $navigation);
85
+            $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
86
+            $this->assign( 'settingsnavigation', $settingsNavigation);
87
+            foreach($navigation as $entry) {
88
+                if ($entry['active']) {
89
+                    $this->assign( 'application', $entry['name'] );
90
+                    break;
91
+                }
92
+            }
93
+
94
+            foreach($settingsNavigation as $entry) {
95
+                if ($entry['active']) {
96
+                    $this->assign( 'application', $entry['name'] );
97
+                    break;
98
+                }
99
+            }
100
+            $userDisplayName = \OC_User::getDisplayName();
101
+            $this->assign('user_displayname', $userDisplayName);
102
+            $this->assign('user_uid', \OC_User::getUser());
103
+
104
+            if (\OC_User::getUser() === false) {
105
+                $this->assign('userAvatarSet', false);
106
+            } else {
107
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
108
+                $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
109
+            }
110
+
111
+            // check if app menu icons should be inverted
112
+            try {
113
+                /** @var \OCA\Theming\Util $util */
114
+                $util = \OC::$server->query(\OCA\Theming\Util::class);
115
+                $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
116
+            } catch (\OCP\AppFramework\QueryException $e) {
117
+                $this->assign('themingInvertMenu', false);
118
+            }
119
+
120
+        } else if ($renderAs == 'error') {
121
+            parent::__construct('core', 'layout.guest', '', false);
122
+            $this->assign('bodyid', 'body-login');
123
+        } else if ($renderAs == 'guest') {
124
+            parent::__construct('core', 'layout.guest');
125
+            $this->assign('bodyid', 'body-login');
126
+        } else if ($renderAs == 'public') {
127
+            parent::__construct('core', 'layout.public');
128
+            $this->assign( 'appid', $appId );
129
+            $this->assign('bodyid', 'body-public');
130
+        } else {
131
+            parent::__construct('core', 'layout.base');
132
+
133
+        }
134
+        // Send the language to our layouts
135
+        $lang = \OC::$server->getL10NFactory()->findLanguage();
136
+        $lang = str_replace('_', '-', $lang);
137
+        $this->assign('language', $lang);
138
+
139
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
140
+            if (empty(self::$versionHash)) {
141
+                $v = \OC_App::getAppVersions();
142
+                $v['core'] = implode('.', \OCP\Util::getVersion());
143
+                self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
144
+            }
145
+        } else {
146
+            self::$versionHash = md5('not installed');
147
+        }
148
+
149
+        // Add the js files
150
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
151
+        $this->assign('jsfiles', array());
152
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
153
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
154
+                $jsConfigHelper = new JSConfigHelper(
155
+                    \OC::$server->getL10N('lib'),
156
+                    \OC::$server->query(Defaults::class),
157
+                    \OC::$server->getAppManager(),
158
+                    \OC::$server->getSession(),
159
+                    \OC::$server->getUserSession()->getUser(),
160
+                    $this->config,
161
+                    \OC::$server->getGroupManager(),
162
+                    \OC::$server->getIniWrapper(),
163
+                    \OC::$server->getURLGenerator(),
164
+                    \OC::$server->getCapabilitiesManager()
165
+                );
166
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
167
+            } else {
168
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
169
+            }
170
+        }
171
+        foreach($jsFiles as $info) {
172
+            $web = $info[1];
173
+            $file = $info[2];
174
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
175
+        }
176
+
177
+        try {
178
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
179
+        } catch (\Exception $e) {
180
+            $pathInfo = '';
181
+        }
182
+
183
+        // Do not initialise scss appdata until we have a fully installed instance
184
+        // Do not load scss for update, errors, installation or login page
185
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
186
+            && !\OCP\Util::needUpgrade()
187
+            && $pathInfo !== ''
188
+            && !preg_match('/^\/login/', $pathInfo)
189
+            && $renderAs !== 'error' && $renderAs !== 'guest'
190
+        ) {
191
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
192
+        } else {
193
+            // If we ignore the scss compiler,
194
+            // we need to load the guest css fallback
195
+            \OC_Util::addStyle('guest');
196
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
197
+        }
198
+
199
+        $this->assign('cssfiles', array());
200
+        $this->assign('printcssfiles', []);
201
+        $this->assign('versionHash', self::$versionHash);
202
+        foreach($cssFiles as $info) {
203
+            $web = $info[1];
204
+            $file = $info[2];
205
+
206
+            if (substr($file, -strlen('print.css')) === 'print.css') {
207
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
208
+            } else {
209
+                $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file)  );
210
+            }
211
+        }
212
+    }
213
+
214
+    /**
215
+     * @param string $path
216
+     * @param string $file
217
+     * @return string
218
+     */
219
+    protected function getVersionHashSuffix($path = false, $file = false) {
220
+        if ($this->config->getSystemValue('debug', false)) {
221
+            // allows chrome workspace mapping in debug mode
222
+            return "";
223
+        }
224
+        $themingSuffix = '';
225
+        $v = [];
226
+
227
+        if ($this->config->getSystemValue('installed', false)) {
228
+            if (\OC::$server->getAppManager()->isInstalled('theming')) {
229
+                $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
230
+            }
231
+            $v = \OC_App::getAppVersions();
232
+        }
233
+
234
+        // Try the webroot path for a match
235
+        if ($path !== false && $path !== '') {
236
+            $appName = $this->getAppNamefromPath($path);
237
+            if(array_key_exists($appName, $v)) {
238
+                $appVersion = $v[$appName];
239
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
240
+            }
241
+        }
242
+        // fallback to the file path instead
243
+        if ($file !== false && $file !== '') {
244
+            $appName = $this->getAppNamefromPath($file);
245
+            if(array_key_exists($appName, $v)) {
246
+                $appVersion = $v[$appName];
247
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
248
+            }
249
+        }
250
+
251
+        return '?v=' . self::$versionHash . $themingSuffix;
252
+    }
253
+
254
+    /**
255
+     * @param array $styles
256
+     * @return array
257
+     */
258
+    static public function findStylesheetFiles($styles, $compileScss = true) {
259
+        // Read the selected theme from the config file
260
+        $theme = \OC_Util::getTheme();
261
+
262
+        if($compileScss) {
263
+            $SCSSCacher = \OC::$server->query(SCSSCacher::class);
264
+        } else {
265
+            $SCSSCacher = null;
266
+        }
267
+
268
+        $locator = new \OC\Template\CSSResourceLocator(
269
+            \OC::$server->getLogger(),
270
+            $theme,
271
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
272
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
273
+            $SCSSCacher
274
+        );
275
+        $locator->find($styles);
276
+        return $locator->getResources();
277
+    }
278
+
279
+    /**
280
+     * @param string $path
281
+     * @return string|boolean
282
+     */
283
+    public function getAppNamefromPath($path) {
284
+        if ($path !== '' && is_string($path)) {
285
+            $pathParts = explode('/', $path);
286
+            if ($pathParts[0] === 'css') {
287
+                // This is a scss request
288
+                return $pathParts[1];
289
+            }
290
+            return end($pathParts);
291
+        }
292
+        return false;
293
+
294
+    }
295
+
296
+    /**
297
+     * @param array $scripts
298
+     * @return array
299
+     */
300
+    static public function findJavascriptFiles($scripts) {
301
+        // Read the selected theme from the config file
302
+        $theme = \OC_Util::getTheme();
303
+
304
+        $locator = new \OC\Template\JSResourceLocator(
305
+            \OC::$server->getLogger(),
306
+            $theme,
307
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
308
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
309
+            \OC::$server->query(JSCombiner::class)
310
+            );
311
+        $locator->find($scripts);
312
+        return $locator->getResources();
313
+    }
314
+
315
+    /**
316
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
317
+     * @param string $filePath Absolute path
318
+     * @return string Relative path
319
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
320
+     */
321
+    public static function convertToRelativePath($filePath) {
322
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
323
+        if(count($relativePath) !== 2) {
324
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
325
+        }
326
+
327
+        return $relativePath[1];
328
+    }
329 329
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -56,44 +56,44 @@  discard block
 block discarded – undo
56 56
 	 * @param string $renderAs
57 57
 	 * @param string $appId application id
58 58
 	 */
59
-	public function __construct( $renderAs, $appId = '' ) {
59
+	public function __construct($renderAs, $appId = '') {
60 60
 
61 61
 		// yes - should be injected ....
62 62
 		$this->config = \OC::$server->getConfig();
63 63
 
64 64
 
65 65
 		// Decide which page we show
66
-		if($renderAs == 'user') {
67
-			parent::__construct( 'core', 'layout.user' );
68
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
66
+		if ($renderAs == 'user') {
67
+			parent::__construct('core', 'layout.user');
68
+			if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) {
69 69
 				$this->assign('bodyid', 'body-settings');
70
-			}else{
70
+			} else {
71 71
 				$this->assign('bodyid', 'body-user');
72 72
 			}
73 73
 
74 74
 			// Code integrity notification
75 75
 			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
76
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
76
+			if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
77 77
 				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
78 78
 			}
79 79
 
80 80
 			// Add navigation entry
81
-			$this->assign( 'application', '');
82
-			$this->assign( 'appid', $appId );
81
+			$this->assign('application', '');
82
+			$this->assign('appid', $appId);
83 83
 			$navigation = \OC::$server->getNavigationManager()->getAll();
84
-			$this->assign( 'navigation', $navigation);
84
+			$this->assign('navigation', $navigation);
85 85
 			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
86
-			$this->assign( 'settingsnavigation', $settingsNavigation);
87
-			foreach($navigation as $entry) {
86
+			$this->assign('settingsnavigation', $settingsNavigation);
87
+			foreach ($navigation as $entry) {
88 88
 				if ($entry['active']) {
89
-					$this->assign( 'application', $entry['name'] );
89
+					$this->assign('application', $entry['name']);
90 90
 					break;
91 91
 				}
92 92
 			}
93 93
 
94
-			foreach($settingsNavigation as $entry) {
94
+			foreach ($settingsNavigation as $entry) {
95 95
 				if ($entry['active']) {
96
-					$this->assign( 'application', $entry['name'] );
96
+					$this->assign('application', $entry['name']);
97 97
 					break;
98 98
 				}
99 99
 			}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 			$this->assign('bodyid', 'body-login');
126 126
 		} else if ($renderAs == 'public') {
127 127
 			parent::__construct('core', 'layout.public');
128
-			$this->assign( 'appid', $appId );
128
+			$this->assign('appid', $appId);
129 129
 			$this->assign('bodyid', 'body-public');
130 130
 		} else {
131 131
 			parent::__construct('core', 'layout.base');
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$lang = str_replace('_', '-', $lang);
137 137
 		$this->assign('language', $lang);
138 138
 
139
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
139
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
140 140
 			if (empty(self::$versionHash)) {
141 141
 				$v = \OC_App::getAppVersions();
142 142
 				$v['core'] = implode('.', \OCP\Util::getVersion());
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
169 169
 			}
170 170
 		}
171
-		foreach($jsFiles as $info) {
171
+		foreach ($jsFiles as $info) {
172 172
 			$web = $info[1];
173 173
 			$file = $info[2];
174
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
174
+			$this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix());
175 175
 		}
176 176
 
177 177
 		try {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 		// Do not initialise scss appdata until we have a fully installed instance
184 184
 		// Do not load scss for update, errors, installation or login page
185
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
185
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)
186 186
 			&& !\OCP\Util::needUpgrade()
187 187
 			&& $pathInfo !== ''
188 188
 			&& !preg_match('/^\/login/', $pathInfo)
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 		$this->assign('cssfiles', array());
200 200
 		$this->assign('printcssfiles', []);
201 201
 		$this->assign('versionHash', self::$versionHash);
202
-		foreach($cssFiles as $info) {
202
+		foreach ($cssFiles as $info) {
203 203
 			$web = $info[1];
204 204
 			$file = $info[2];
205 205
 
206 206
 			if (substr($file, -strlen('print.css')) === 'print.css') {
207
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
207
+				$this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix());
208 208
 			} else {
209
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file)  );
209
+				$this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix($web, $file));
210 210
 			}
211 211
 		}
212 212
 	}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 		if ($this->config->getSystemValue('installed', false)) {
228 228
 			if (\OC::$server->getAppManager()->isInstalled('theming')) {
229
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
229
+				$themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0');
230 230
 			}
231 231
 			$v = \OC_App::getAppVersions();
232 232
 		}
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
 		// Try the webroot path for a match
235 235
 		if ($path !== false && $path !== '') {
236 236
 			$appName = $this->getAppNamefromPath($path);
237
-			if(array_key_exists($appName, $v)) {
237
+			if (array_key_exists($appName, $v)) {
238 238
 				$appVersion = $v[$appName];
239
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
239
+				return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix;
240 240
 			}
241 241
 		}
242 242
 		// fallback to the file path instead
243 243
 		if ($file !== false && $file !== '') {
244 244
 			$appName = $this->getAppNamefromPath($file);
245
-			if(array_key_exists($appName, $v)) {
245
+			if (array_key_exists($appName, $v)) {
246 246
 				$appVersion = $v[$appName];
247
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
247
+				return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix;
248 248
 			}
249 249
 		}
250 250
 
251
-		return '?v=' . self::$versionHash . $themingSuffix;
251
+		return '?v='.self::$versionHash.$themingSuffix;
252 252
 	}
253 253
 
254 254
 	/**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		// Read the selected theme from the config file
260 260
 		$theme = \OC_Util::getTheme();
261 261
 
262
-		if($compileScss) {
262
+		if ($compileScss) {
263 263
 			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
264 264
 		} else {
265 265
 			$SCSSCacher = null;
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 		$locator = new \OC\Template\CSSResourceLocator(
269 269
 			\OC::$server->getLogger(),
270 270
 			$theme,
271
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
272
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
271
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
272
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
273 273
 			$SCSSCacher
274 274
 		);
275 275
 		$locator->find($styles);
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 		$locator = new \OC\Template\JSResourceLocator(
305 305
 			\OC::$server->getLogger(),
306 306
 			$theme,
307
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
308
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
307
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
308
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
309 309
 			\OC::$server->query(JSCombiner::class)
310 310
 			);
311 311
 		$locator->find($scripts);
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public static function convertToRelativePath($filePath) {
322 322
 		$relativePath = explode(\OC::$SERVERROOT, $filePath);
323
-		if(count($relativePath) !== 2) {
323
+		if (count($relativePath) !== 2) {
324 324
 			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
325 325
 		}
326 326
 
Please login to merge, or discard this patch.