Passed
Push — master ( b93e1e...342765 )
by Roeland
34:24 queued 23:05
created
lib/private/Migration/BackgroundRepair.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function execute($jobList, ILogger $logger = null) {
59 59
 		// add an interval of 15 mins
60
-		$this->setInterval(15*60);
60
+		$this->setInterval(15 * 60);
61 61
 
62 62
 		$this->jobList = $jobList;
63 63
 		$this->logger = $logger;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		try {
91 91
 			$repair->addStep($step);
92 92
 		} catch (\Exception $ex) {
93
-			$this->logger->logException($ex,[
93
+			$this->logger->logException($ex, [
94 94
 				'app' => 'migration'
95 95
 			]);
96 96
 
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -39,82 +39,82 @@
 block discarded – undo
39 39
  */
40 40
 class BackgroundRepair extends TimedJob {
41 41
 
42
-	/** @var IJobList */
43
-	private $jobList;
44
-
45
-	/** @var ILogger */
46
-	private $logger;
47
-
48
-	/** @var EventDispatcherInterface */
49
-	private $dispatcher;
50
-
51
-	public function __construct(EventDispatcherInterface $dispatcher) {
52
-		$this->dispatcher = $dispatcher;
53
-	}
54
-
55
-	/**
56
-	 * run the job, then remove it from the job list
57
-	 *
58
-	 * @param JobList $jobList
59
-	 * @param ILogger|null $logger
60
-	 */
61
-	public function execute($jobList, ILogger $logger = null) {
62
-		// add an interval of 15 mins
63
-		$this->setInterval(15*60);
64
-
65
-		$this->jobList = $jobList;
66
-		$this->logger = $logger;
67
-		parent::execute($jobList, $logger);
68
-	}
69
-
70
-	/**
71
-	 * @param array $argument
72
-	 * @throws \Exception
73
-	 * @throws \OC\NeedsUpdateException
74
-	 */
75
-	protected function run($argument) {
76
-		if (!isset($argument['app']) || !isset($argument['step'])) {
77
-			// remove the job - we can never execute it
78
-			$this->jobList->remove($this, $this->argument);
79
-			return;
80
-		}
81
-		$app = $argument['app'];
82
-
83
-		try {
84
-			$this->loadApp($app);
85
-		} catch (NeedsUpdateException $ex) {
86
-			// as long as the app is not yet done with it's offline migration
87
-			// we better not start with the live migration
88
-			return;
89
-		}
90
-
91
-		$step = $argument['step'];
92
-		$repair = new Repair([], $this->dispatcher);
93
-		try {
94
-			$repair->addStep($step);
95
-		} catch (\Exception $ex) {
96
-			$this->logger->logException($ex,[
97
-				'app' => 'migration'
98
-			]);
99
-
100
-			// remove the job - we can never execute it
101
-			$this->jobList->remove($this, $this->argument);
102
-			return;
103
-		}
104
-
105
-		// execute the repair step
106
-		$repair->run();
107
-
108
-		// remove the job once executed successfully
109
-		$this->jobList->remove($this, $this->argument);
110
-	}
111
-
112
-	/**
113
-	 * @codeCoverageIgnore
114
-	 * @param $app
115
-	 * @throws NeedsUpdateException
116
-	 */
117
-	protected function loadApp($app) {
118
-		OC_App::loadApp($app);
119
-	}
42
+    /** @var IJobList */
43
+    private $jobList;
44
+
45
+    /** @var ILogger */
46
+    private $logger;
47
+
48
+    /** @var EventDispatcherInterface */
49
+    private $dispatcher;
50
+
51
+    public function __construct(EventDispatcherInterface $dispatcher) {
52
+        $this->dispatcher = $dispatcher;
53
+    }
54
+
55
+    /**
56
+     * run the job, then remove it from the job list
57
+     *
58
+     * @param JobList $jobList
59
+     * @param ILogger|null $logger
60
+     */
61
+    public function execute($jobList, ILogger $logger = null) {
62
+        // add an interval of 15 mins
63
+        $this->setInterval(15*60);
64
+
65
+        $this->jobList = $jobList;
66
+        $this->logger = $logger;
67
+        parent::execute($jobList, $logger);
68
+    }
69
+
70
+    /**
71
+     * @param array $argument
72
+     * @throws \Exception
73
+     * @throws \OC\NeedsUpdateException
74
+     */
75
+    protected function run($argument) {
76
+        if (!isset($argument['app']) || !isset($argument['step'])) {
77
+            // remove the job - we can never execute it
78
+            $this->jobList->remove($this, $this->argument);
79
+            return;
80
+        }
81
+        $app = $argument['app'];
82
+
83
+        try {
84
+            $this->loadApp($app);
85
+        } catch (NeedsUpdateException $ex) {
86
+            // as long as the app is not yet done with it's offline migration
87
+            // we better not start with the live migration
88
+            return;
89
+        }
90
+
91
+        $step = $argument['step'];
92
+        $repair = new Repair([], $this->dispatcher);
93
+        try {
94
+            $repair->addStep($step);
95
+        } catch (\Exception $ex) {
96
+            $this->logger->logException($ex,[
97
+                'app' => 'migration'
98
+            ]);
99
+
100
+            // remove the job - we can never execute it
101
+            $this->jobList->remove($this, $this->argument);
102
+            return;
103
+        }
104
+
105
+        // execute the repair step
106
+        $repair->run();
107
+
108
+        // remove the job once executed successfully
109
+        $this->jobList->remove($this, $this->argument);
110
+    }
111
+
112
+    /**
113
+     * @codeCoverageIgnore
114
+     * @param $app
115
+     * @throws NeedsUpdateException
116
+     */
117
+    protected function loadApp($app) {
118
+        OC_App::loadApp($app);
119
+    }
120 120
 }
Please login to merge, or discard this patch.
lib/private/Command/QueueBus.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 		if ($command instanceof ICommand) {
56 56
 			// ensure the command can be serialized
57 57
 			$serialized = serialize($command);
58
-			if(strlen($serialized) > 4000) {
58
+			if (strlen($serialized) > 4000) {
59 59
 				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60 60
 			}
61 61
 			$unserialized = unserialize($serialized);
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,48 +26,48 @@
 block discarded – undo
26 26
 use OCP\Command\ICommand;
27 27
 
28 28
 class QueueBus implements IBus {
29
-	/**
30
-	 * @var ICommand[]|callable[]
31
-	 */
32
-	private $queue = [];
29
+    /**
30
+     * @var ICommand[]|callable[]
31
+     */
32
+    private $queue = [];
33 33
 
34
-	/**
35
-	 * Schedule a command to be fired
36
-	 *
37
-	 * @param \OCP\Command\ICommand | callable $command
38
-	 */
39
-	public function push($command) {
40
-		$this->queue[] = $command;
41
-	}
34
+    /**
35
+     * Schedule a command to be fired
36
+     *
37
+     * @param \OCP\Command\ICommand | callable $command
38
+     */
39
+    public function push($command) {
40
+        $this->queue[] = $command;
41
+    }
42 42
 
43
-	/**
44
-	 * Require all commands using a trait to be run synchronous
45
-	 *
46
-	 * @param string $trait
47
-	 */
48
-	public function requireSync($trait) {
49
-	}
43
+    /**
44
+     * Require all commands using a trait to be run synchronous
45
+     *
46
+     * @param string $trait
47
+     */
48
+    public function requireSync($trait) {
49
+    }
50 50
 
51
-	/**
52
-	 * @param \OCP\Command\ICommand | callable $command
53
-	 */
54
-	private function runCommand($command) {
55
-		if ($command instanceof ICommand) {
56
-			// ensure the command can be serialized
57
-			$serialized = serialize($command);
58
-			if(strlen($serialized) > 4000) {
59
-				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60
-			}
61
-			$unserialized = unserialize($serialized);
62
-			$unserialized->handle();
63
-		} else {
64
-			$command();
65
-		}
66
-	}
51
+    /**
52
+     * @param \OCP\Command\ICommand | callable $command
53
+     */
54
+    private function runCommand($command) {
55
+        if ($command instanceof ICommand) {
56
+            // ensure the command can be serialized
57
+            $serialized = serialize($command);
58
+            if(strlen($serialized) > 4000) {
59
+                throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60
+            }
61
+            $unserialized = unserialize($serialized);
62
+            $unserialized->handle();
63
+        } else {
64
+            $command();
65
+        }
66
+    }
67 67
 
68
-	public function run() {
69
-		while ($command = array_shift($this->queue)) {
70
-			$this->runCommand($command);
71
-		}
72
-	}
68
+    public function run() {
69
+        while ($command = array_shift($this->queue)) {
70
+            $this->runCommand($command);
71
+        }
72
+    }
73 73
 }
Please login to merge, or discard this patch.
lib/private/Command/CallableJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OC\BackgroundJob\QueuedJob;
26 26
 
27 27
 class CallableJob extends QueuedJob {
28
-	protected function run($serializedCallable) {
29
-		$callable = unserialize($serializedCallable);
30
-		if (is_callable($callable)) {
31
-			$callable();
32
-		} else {
33
-			throw new \InvalidArgumentException('Invalid serialized callable');
34
-		}
35
-	}
28
+    protected function run($serializedCallable) {
29
+        $callable = unserialize($serializedCallable);
30
+        if (is_callable($callable)) {
31
+            $callable();
32
+        } else {
33
+            throw new \InvalidArgumentException('Invalid serialized callable');
34
+        }
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Command/ClosureJob.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
 use SuperClosure\Serializer;
27 27
 
28 28
 class ClosureJob extends QueuedJob {
29
-	protected function run($serializedCallable) {
30
-		$serializer = new Serializer();
31
-		$callable = $serializer->unserialize($serializedCallable);
32
-		if (is_callable($callable)) {
33
-			$callable();
34
-		} else {
35
-			throw new \InvalidArgumentException('Invalid serialized callable');
36
-		}
37
-	}
29
+    protected function run($serializedCallable) {
30
+        $serializer = new Serializer();
31
+        $callable = $serializer->unserialize($serializedCallable);
32
+        if (is_callable($callable)) {
33
+            $callable();
34
+        } else {
35
+            throw new \InvalidArgumentException('Invalid serialized callable');
36
+        }
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/Command/FileAccess.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user){
29
-		\OC_Util::setupFS($user->getUID());
30
-	}
28
+    protected function setupFS(IUser $user){
29
+        \OC_Util::setupFS($user->getUID());
30
+    }
31 31
 
32
-	protected function getUserFolder(IUser $user) {
33
-		$this->setupFS($user);
34
-		return \OC::$server->getUserFolder($user->getUID());
35
-	}
32
+    protected function getUserFolder(IUser $user) {
33
+        $this->setupFS($user);
34
+        return \OC::$server->getUserFolder($user->getUID());
35
+    }
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user){
28
+	protected function setupFS(IUser $user) {
29 29
 		\OC_Util::setupFS($user->getUID());
30 30
 	}
31 31
 
Please login to merge, or discard this patch.
lib/private/Command/CommandJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  * Wrap a command in the background job interface
30 30
  */
31 31
 class CommandJob extends QueuedJob {
32
-	protected function run($serializedCommand) {
33
-		$command = unserialize($serializedCommand);
34
-		if ($command instanceof ICommand) {
35
-			$command->handle();
36
-		} else {
37
-			throw new \InvalidArgumentException('Invalid serialized command');
38
-		}
39
-	}
32
+    protected function run($serializedCommand) {
33
+        $command = unserialize($serializedCommand);
34
+        if ($command instanceof ICommand) {
35
+            $command->handle();
36
+        } else {
37
+            throw new \InvalidArgumentException('Invalid serialized command');
38
+        }
39
+    }
40 40
 }
Please login to merge, or discard this patch.
lib/private/Template/Base.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,8 +114,7 @@  discard block
 block discarded – undo
114 114
 	public function append( $key, $value ) {
115 115
 		if( array_key_exists( $key, $this->vars )) {
116 116
 			$this->vars[$key][] = $value;
117
-		}
118
-		else{
117
+		} else{
119 118
 			$this->vars[$key] = array( $value );
120 119
 		}
121 120
 	}
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
 		$data = $this->fetchPage();
131 130
 		if( $data === false ) {
132 131
 			return false;
133
-		}
134
-		else{
132
+		} else{
135 133
 			print $data;
136 134
 			return true;
137 135
 		}
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @param \OCP\IL10N $l10n
47 47
 	 * @param Defaults $theme
48 48
 	 */
49
-	public function __construct($template, $requestToken, $l10n, $theme ) {
49
+	public function __construct($template, $requestToken, $l10n, $theme) {
50 50
 		$this->vars = array();
51 51
 		$this->vars['requesttoken'] = $requestToken;
52 52
 		$this->l10n = $l10n;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
65 65
 		// Check if the app is in the app folder or in the root
66
-		if( file_exists($app_dir.'/templates/' )) {
66
+		if (file_exists($app_dir.'/templates/')) {
67 67
 			return [
68 68
 				$serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
69 69
 				$app_dir.'/templates/',
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * If the key existed before, it will be overwritten
100 100
 	 */
101
-	public function assign( $key, $value) {
101
+	public function assign($key, $value) {
102 102
 		$this->vars[$key] = $value;
103 103
 		return true;
104 104
 	}
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	 * exists, the value will be appended. It can be accessed via
114 114
 	 * $_[$key][$position] in the template.
115 115
 	 */
116
-	public function append( $key, $value ) {
117
-		if( array_key_exists( $key, $this->vars )) {
116
+	public function append($key, $value) {
117
+		if (array_key_exists($key, $this->vars)) {
118 118
 			$this->vars[$key][] = $value;
119 119
 		}
120
-		else{
121
-			$this->vars[$key] = array( $value );
120
+		else {
121
+			$this->vars[$key] = array($value);
122 122
 		}
123 123
 	}
124 124
 
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function printPage() {
132 132
 		$data = $this->fetchPage();
133
-		if( $data === false ) {
133
+		if ($data === false) {
134 134
 			return false;
135 135
 		}
136
-		else{
136
+		else {
137 137
 			print $data;
138 138
 			return true;
139 139
 		}
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 		$l = $this->l10n;
167 167
 		$theme = $this->theme;
168 168
 
169
-		if(!is_null($additionalParams)) {
170
-			$_ = array_merge( $additionalParams, $this->vars );
169
+		if (!is_null($additionalParams)) {
170
+			$_ = array_merge($additionalParams, $this->vars);
171 171
 			foreach ($_ as $var => $value) {
172 172
 				${$var} = $value;
173 173
 			}
Please login to merge, or discard this patch.
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -31,160 +31,160 @@
 block discarded – undo
31 31
 use OCP\Defaults;
32 32
 
33 33
 class Base {
34
-	private $template; // The template
35
-	private $vars; // Vars
36
-
37
-	/** @var \OCP\IL10N */
38
-	private $l10n;
39
-
40
-	/** @var Defaults */
41
-	private $theme;
42
-
43
-	/**
44
-	 * @param string $template
45
-	 * @param string $requestToken
46
-	 * @param \OCP\IL10N $l10n
47
-	 * @param Defaults $theme
48
-	 */
49
-	public function __construct($template, $requestToken, $l10n, $theme ) {
50
-		$this->vars = array();
51
-		$this->vars['requesttoken'] = $requestToken;
52
-		$this->l10n = $l10n;
53
-		$this->template = $template;
54
-		$this->theme = $theme;
55
-	}
56
-
57
-	/**
58
-	 * @param string $serverRoot
59
-	 * @param string|false $app_dir
60
-	 * @param string $theme
61
-	 * @param string $app
62
-	 * @return string[]
63
-	 */
64
-	protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
65
-		// Check if the app is in the app folder or in the root
66
-		if( file_exists($app_dir.'/templates/' )) {
67
-			return [
68
-				$serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
69
-				$app_dir.'/templates/',
70
-			];
71
-		}
72
-		return [
73
-			$serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
74
-			$serverRoot.'/'.$app.'/templates/',
75
-		];
76
-	}
77
-
78
-	/**
79
-	 * @param string $serverRoot
80
-	 * @param string $theme
81
-	 * @return string[]
82
-	 */
83
-	protected function getCoreTemplateDirs($theme, $serverRoot) {
84
-		return [
85
-			$serverRoot.'/themes/'.$theme.'/core/templates/',
86
-			$serverRoot.'/core/templates/',
87
-		];
88
-	}
89
-
90
-	/**
91
-	 * Assign variables
92
-	 * @param string $key key
93
-	 * @param array|bool|integer|string $value value
94
-	 * @return bool
95
-	 *
96
-	 * This function assigns a variable. It can be accessed via $_[$key] in
97
-	 * the template.
98
-	 *
99
-	 * If the key existed before, it will be overwritten
100
-	 */
101
-	public function assign( $key, $value) {
102
-		$this->vars[$key] = $value;
103
-		return true;
104
-	}
105
-
106
-	/**
107
-	 * Appends a variable
108
-	 * @param string $key key
109
-	 * @param mixed $value value
110
-	 *
111
-	 * This function assigns a variable in an array context. If the key already
112
-	 * exists, the value will be appended. It can be accessed via
113
-	 * $_[$key][$position] in the template.
114
-	 */
115
-	public function append( $key, $value ) {
116
-		if( array_key_exists( $key, $this->vars )) {
117
-			$this->vars[$key][] = $value;
118
-		}
119
-		else{
120
-			$this->vars[$key] = array( $value );
121
-		}
122
-	}
123
-
124
-	/**
125
-	 * Prints the proceeded template
126
-	 * @return bool
127
-	 *
128
-	 * This function proceeds the template and prints its output.
129
-	 */
130
-	public function printPage() {
131
-		$data = $this->fetchPage();
132
-		if( $data === false ) {
133
-			return false;
134
-		}
135
-		else{
136
-			print $data;
137
-			return true;
138
-		}
139
-	}
140
-
141
-	/**
142
-	 * Process the template
143
-	 *
144
-	 * @param array|null $additionalParams
145
-	 * @return string This function processes the template.
146
-	 *
147
-	 * This function processes the template.
148
-	 */
149
-	public function fetchPage($additionalParams = null) {
150
-		return $this->load($this->template, $additionalParams);
151
-	}
152
-
153
-	/**
154
-	 * doing the actual work
155
-	 *
156
-	 * @param string $file
157
-	 * @param array|null $additionalParams
158
-	 * @return string content
159
-	 *
160
-	 * Includes the template file, fetches its output
161
-	 */
162
-	protected function load($file, $additionalParams = null) {
163
-		// Register the variables
164
-		$_ = $this->vars;
165
-		$l = $this->l10n;
166
-		$theme = $this->theme;
167
-
168
-		if(!is_null($additionalParams)) {
169
-			$_ = array_merge( $additionalParams, $this->vars );
170
-			foreach ($_ as $var => $value) {
171
-				${$var} = $value;
172
-			}
173
-		}
174
-
175
-		// Include
176
-		ob_start();
177
-		try {
178
-			include $file;
179
-			$data = ob_get_contents();
180
-		} catch (\Exception $e) {
181
-			@ob_end_clean();
182
-			throw $e;
183
-		}
184
-		@ob_end_clean();
185
-
186
-		// Return data
187
-		return $data;
188
-	}
34
+    private $template; // The template
35
+    private $vars; // Vars
36
+
37
+    /** @var \OCP\IL10N */
38
+    private $l10n;
39
+
40
+    /** @var Defaults */
41
+    private $theme;
42
+
43
+    /**
44
+     * @param string $template
45
+     * @param string $requestToken
46
+     * @param \OCP\IL10N $l10n
47
+     * @param Defaults $theme
48
+     */
49
+    public function __construct($template, $requestToken, $l10n, $theme ) {
50
+        $this->vars = array();
51
+        $this->vars['requesttoken'] = $requestToken;
52
+        $this->l10n = $l10n;
53
+        $this->template = $template;
54
+        $this->theme = $theme;
55
+    }
56
+
57
+    /**
58
+     * @param string $serverRoot
59
+     * @param string|false $app_dir
60
+     * @param string $theme
61
+     * @param string $app
62
+     * @return string[]
63
+     */
64
+    protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
65
+        // Check if the app is in the app folder or in the root
66
+        if( file_exists($app_dir.'/templates/' )) {
67
+            return [
68
+                $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
69
+                $app_dir.'/templates/',
70
+            ];
71
+        }
72
+        return [
73
+            $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
74
+            $serverRoot.'/'.$app.'/templates/',
75
+        ];
76
+    }
77
+
78
+    /**
79
+     * @param string $serverRoot
80
+     * @param string $theme
81
+     * @return string[]
82
+     */
83
+    protected function getCoreTemplateDirs($theme, $serverRoot) {
84
+        return [
85
+            $serverRoot.'/themes/'.$theme.'/core/templates/',
86
+            $serverRoot.'/core/templates/',
87
+        ];
88
+    }
89
+
90
+    /**
91
+     * Assign variables
92
+     * @param string $key key
93
+     * @param array|bool|integer|string $value value
94
+     * @return bool
95
+     *
96
+     * This function assigns a variable. It can be accessed via $_[$key] in
97
+     * the template.
98
+     *
99
+     * If the key existed before, it will be overwritten
100
+     */
101
+    public function assign( $key, $value) {
102
+        $this->vars[$key] = $value;
103
+        return true;
104
+    }
105
+
106
+    /**
107
+     * Appends a variable
108
+     * @param string $key key
109
+     * @param mixed $value value
110
+     *
111
+     * This function assigns a variable in an array context. If the key already
112
+     * exists, the value will be appended. It can be accessed via
113
+     * $_[$key][$position] in the template.
114
+     */
115
+    public function append( $key, $value ) {
116
+        if( array_key_exists( $key, $this->vars )) {
117
+            $this->vars[$key][] = $value;
118
+        }
119
+        else{
120
+            $this->vars[$key] = array( $value );
121
+        }
122
+    }
123
+
124
+    /**
125
+     * Prints the proceeded template
126
+     * @return bool
127
+     *
128
+     * This function proceeds the template and prints its output.
129
+     */
130
+    public function printPage() {
131
+        $data = $this->fetchPage();
132
+        if( $data === false ) {
133
+            return false;
134
+        }
135
+        else{
136
+            print $data;
137
+            return true;
138
+        }
139
+    }
140
+
141
+    /**
142
+     * Process the template
143
+     *
144
+     * @param array|null $additionalParams
145
+     * @return string This function processes the template.
146
+     *
147
+     * This function processes the template.
148
+     */
149
+    public function fetchPage($additionalParams = null) {
150
+        return $this->load($this->template, $additionalParams);
151
+    }
152
+
153
+    /**
154
+     * doing the actual work
155
+     *
156
+     * @param string $file
157
+     * @param array|null $additionalParams
158
+     * @return string content
159
+     *
160
+     * Includes the template file, fetches its output
161
+     */
162
+    protected function load($file, $additionalParams = null) {
163
+        // Register the variables
164
+        $_ = $this->vars;
165
+        $l = $this->l10n;
166
+        $theme = $this->theme;
167
+
168
+        if(!is_null($additionalParams)) {
169
+            $_ = array_merge( $additionalParams, $this->vars );
170
+            foreach ($_ as $var => $value) {
171
+                ${$var} = $value;
172
+            }
173
+        }
174
+
175
+        // Include
176
+        ob_start();
177
+        try {
178
+            include $file;
179
+            $data = ob_get_contents();
180
+        } catch (\Exception $e) {
181
+            @ob_end_clean();
182
+            throw $e;
183
+        }
184
+        @ob_end_clean();
185
+
186
+        // Return data
187
+        return $data;
188
+    }
189 189
 
190 190
 }
Please login to merge, or discard this patch.
lib/private/Template/ResourceNotFoundException.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@
 block discarded – undo
24 24
 namespace OC\Template;
25 25
 
26 26
 class ResourceNotFoundException extends \LogicException {
27
-	protected $resource;
28
-	protected $webPath;
27
+    protected $resource;
28
+    protected $webPath;
29 29
 
30
-	/**
31
-	 * @param string $resource
32
-	 * @param string $webPath
33
-	 */
34
-	public function __construct($resource, $webPath) {
35
-		parent::__construct('Resource not found');
36
-		$this->resource = $resource;
37
-		$this->webPath = $webPath;
38
-	}
30
+    /**
31
+     * @param string $resource
32
+     * @param string $webPath
33
+     */
34
+    public function __construct($resource, $webPath) {
35
+        parent::__construct('Resource not found');
36
+        $this->resource = $resource;
37
+        $this->webPath = $webPath;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getResourcePath() {
44
+        return $this->webPath . '/' . $this->resource;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,6 +41,6 @@
 block discarded – undo
41 41
 	 * @return string
42 42
 	 */
43 43
 	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
44
+		return $this->webPath.'/'.$this->resource;
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
lib/private/Template/TemplateFileLocator.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -26,37 +26,37 @@
 block discarded – undo
26 26
 namespace OC\Template;
27 27
 
28 28
 class TemplateFileLocator {
29
-	protected $dirs;
30
-	private $path;
29
+    protected $dirs;
30
+    private $path;
31 31
 
32
-	/**
33
-	 * @param string[] $dirs
34
-	 */
35
-	public function __construct( $dirs ) {
36
-		$this->dirs = $dirs;
37
-	}
32
+    /**
33
+     * @param string[] $dirs
34
+     */
35
+    public function __construct( $dirs ) {
36
+        $this->dirs = $dirs;
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $template
41
-	 * @return string
42
-	 * @throws \Exception
43
-	 */
44
-	public function find( $template ) {
45
-		if ($template === '') {
46
-			throw new \InvalidArgumentException('Empty template name');
47
-		}
39
+    /**
40
+     * @param string $template
41
+     * @return string
42
+     * @throws \Exception
43
+     */
44
+    public function find( $template ) {
45
+        if ($template === '') {
46
+            throw new \InvalidArgumentException('Empty template name');
47
+        }
48 48
 
49
-		foreach($this->dirs as $dir) {
50
-			$file = $dir.$template.'.php';
51
-			if (is_file($file)) {
52
-				$this->path = $dir;
53
-				return $file;
54
-			}
55
-		}
56
-		throw new \Exception('template file not found: template:'.$template);
57
-	}
49
+        foreach($this->dirs as $dir) {
50
+            $file = $dir.$template.'.php';
51
+            if (is_file($file)) {
52
+                $this->path = $dir;
53
+                return $file;
54
+            }
55
+        }
56
+        throw new \Exception('template file not found: template:'.$template);
57
+    }
58 58
 
59
-	public function getPath() {
60
-		return $this->path;
61
-	}
59
+    public function getPath() {
60
+        return $this->path;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @param string[] $dirs
34 34
 	 */
35
-	public function __construct( $dirs ) {
35
+	public function __construct($dirs) {
36 36
 		$this->dirs = $dirs;
37 37
 	}
38 38
 
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 * @return string
42 42
 	 * @throws \Exception
43 43
 	 */
44
-	public function find( $template ) {
44
+	public function find($template) {
45 45
 		if ($template === '') {
46 46
 			throw new \InvalidArgumentException('Empty template name');
47 47
 		}
48 48
 
49
-		foreach($this->dirs as $dir) {
49
+		foreach ($this->dirs as $dir) {
50 50
 			$file = $dir.$template.'.php';
51 51
 			if (is_file($file)) {
52 52
 				$this->path = $dir;
Please login to merge, or discard this patch.