diff options
Diffstat (limited to 'lib/public/appframework/http')
-rw-r--r-- | lib/public/appframework/http/contentsecuritypolicy.php | 88 | ||||
-rw-r--r-- | lib/public/appframework/http/datadisplayresponse.php | 88 | ||||
-rw-r--r-- | lib/public/appframework/http/datadownloadresponse.php | 63 | ||||
-rw-r--r-- | lib/public/appframework/http/dataresponse.php | 83 | ||||
-rw-r--r-- | lib/public/appframework/http/downloadresponse.php | 52 | ||||
-rw-r--r-- | lib/public/appframework/http/emptycontentsecuritypolicy.php | 385 | ||||
-rw-r--r-- | lib/public/appframework/http/icallbackresponse.php | 43 | ||||
-rw-r--r-- | lib/public/appframework/http/ioutput.php | 77 | ||||
-rw-r--r-- | lib/public/appframework/http/jsonresponse.php | 100 | ||||
-rw-r--r-- | lib/public/appframework/http/notfoundresponse.php | 49 | ||||
-rw-r--r-- | lib/public/appframework/http/ocsresponse.php | 91 | ||||
-rw-r--r-- | lib/public/appframework/http/redirectresponse.php | 61 | ||||
-rw-r--r-- | lib/public/appframework/http/response.php | 326 | ||||
-rw-r--r-- | lib/public/appframework/http/streamresponse.php | 64 | ||||
-rw-r--r-- | lib/public/appframework/http/templateresponse.php | 159 |
15 files changed, 0 insertions, 1729 deletions
diff --git a/lib/public/appframework/http/contentsecuritypolicy.php b/lib/public/appframework/http/contentsecuritypolicy.php deleted file mode 100644 index 7762ca809a2..00000000000 --- a/lib/public/appframework/http/contentsecuritypolicy.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php -/** - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author sualko <klaus@jsxc.org> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * Class ContentSecurityPolicy is a simple helper which allows applications to - * modify the Content-Security-Policy sent by ownCloud. Per default only JavaScript, - * stylesheets, images, fonts, media and connections from the same domain - * ('self') are allowed. - * - * Even if a value gets modified above defaults will still get appended. Please - * notice that ownCloud ships already with sensible defaults and those policies - * should require no modification at all for most use-cases. - * - * @package OCP\AppFramework\Http - * @since 8.1.0 - */ -class ContentSecurityPolicy extends EmptyContentSecurityPolicy { - /** @var bool Whether inline JS snippets are allowed */ - protected $inlineScriptAllowed = false; - /** - * @var bool Whether eval in JS scripts is allowed - * TODO: Disallow per default - * @link https://github.com/owncloud/core/issues/11925 - */ - protected $evalScriptAllowed = true; - /** @var array Domains from which scripts can get loaded */ - protected $allowedScriptDomains = [ - '\'self\'', - ]; - /** - * @var bool Whether inline CSS is allowed - * TODO: Disallow per default - * @link https://github.com/owncloud/core/issues/13458 - */ - protected $inlineStyleAllowed = true; - /** @var array Domains from which CSS can get loaded */ - protected $allowedStyleDomains = [ - '\'self\'', - ]; - /** @var array Domains from which images can get loaded */ - protected $allowedImageDomains = [ - '\'self\'', - 'data:', - 'blob:', - ]; - /** @var array Domains to which connections can be done */ - protected $allowedConnectDomains = [ - '\'self\'', - ]; - /** @var array Domains from which media elements can be loaded */ - protected $allowedMediaDomains = [ - '\'self\'', - ]; - /** @var array Domains from which object elements can be loaded */ - protected $allowedObjectDomains = []; - /** @var array Domains from which iframes can be loaded */ - protected $allowedFrameDomains = []; - /** @var array Domains from which fonts can be loaded */ - protected $allowedFontDomains = [ - '\'self\'', - ]; - /** @var array Domains from which web-workers and nested browsing content can load elements */ - protected $allowedChildSrcDomains = []; -} diff --git a/lib/public/appframework/http/datadisplayresponse.php b/lib/public/appframework/http/datadisplayresponse.php deleted file mode 100644 index 4209c86a059..00000000000 --- a/lib/public/appframework/http/datadisplayresponse.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php -/** - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <rullzer@owncloud.com> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * Class DataDisplayResponse - * - * @package OCP\AppFramework\Http - * @since 8.1.0 - */ -class DataDisplayResponse extends Response { - - /** - * response data - * @var string; - */ - protected $data; - - - /** - * @param string $data the data to display - * @param int $statusCode the Http status code, defaults to 200 - * @param array $headers additional key value based headers - * @since 8.1.0 - */ - public function __construct($data="", $statusCode=Http::STATUS_OK, - $headers=[]) { - $this->data = $data; - $this->setStatus($statusCode); - $this->setHeaders(array_merge($this->getHeaders(), $headers)); - $this->addHeader('Content-Disposition', 'inline; filename=""'); - } - - /** - * Outputs data. No processing is done. - * @return string - * @since 8.1.0 - */ - public function render() { - return $this->data; - } - - - /** - * Sets values in the data - * @param string $data the data to display - * @return DataDisplayResponse Reference to this object - * @since 8.1.0 - */ - public function setData($data){ - $this->data = $data; - - return $this; - } - - - /** - * Used to get the set parameters - * @return string the data - * @since 8.1.0 - */ - public function getData(){ - return $this->data; - } - -} diff --git a/lib/public/appframework/http/datadownloadresponse.php b/lib/public/appframework/http/datadownloadresponse.php deleted file mode 100644 index 55ef4e6c82c..00000000000 --- a/lib/public/appframework/http/datadownloadresponse.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * @author Georg Ehrke <georg@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -namespace OCP\AppFramework\Http; - -/** - * Class DataDownloadResponse - * - * @package OCP\AppFramework\Http - * @since 8.0.0 - */ -class DataDownloadResponse extends DownloadResponse { - /** - * @var string - */ - private $data; - - /** - * Creates a response that prompts the user to download the text - * @param string $data text to be downloaded - * @param string $filename the name that the downloaded file should have - * @param string $contentType the mimetype that the downloaded file should have - * @since 8.0.0 - */ - public function __construct($data, $filename, $contentType) { - $this->data = $data; - parent::__construct($filename, $contentType); - } - - /** - * @param string $data - * @since 8.0.0 - */ - public function setData($data) { - $this->data = $data; - } - - /** - * @return string - * @since 8.0.0 - */ - public function render() { - return $this->data; - } -} diff --git a/lib/public/appframework/http/dataresponse.php b/lib/public/appframework/http/dataresponse.php deleted file mode 100644 index 3ec4e2bdc32..00000000000 --- a/lib/public/appframework/http/dataresponse.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -/** - * Public interface of ownCloud for apps to use. - * AppFramework\HTTP\DataResponse class - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * A generic DataResponse class that is used to return generic data responses - * for responders to transform - * @since 8.0.0 - */ -class DataResponse extends Response { - - /** - * response data - * @var array|object - */ - protected $data; - - - /** - * @param array|object $data the object or array that should be transformed - * @param int $statusCode the Http status code, defaults to 200 - * @param array $headers additional key value based headers - * @since 8.0.0 - */ - public function __construct($data=array(), $statusCode=Http::STATUS_OK, - array $headers=array()) { - $this->data = $data; - $this->setStatus($statusCode); - $this->setHeaders(array_merge($this->getHeaders(), $headers)); - } - - - /** - * Sets values in the data json array - * @param array|object $data an array or object which will be transformed - * @return DataResponse Reference to this object - * @since 8.0.0 - */ - public function setData($data){ - $this->data = $data; - - return $this; - } - - - /** - * Used to get the set parameters - * @return array the data - * @since 8.0.0 - */ - public function getData(){ - return $this->data; - } - - -} diff --git a/lib/public/appframework/http/downloadresponse.php b/lib/public/appframework/http/downloadresponse.php deleted file mode 100644 index af0d76951ca..00000000000 --- a/lib/public/appframework/http/downloadresponse.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - - -namespace OCP\AppFramework\Http; - - -/** - * Prompts the user to download the a file - * @since 7.0.0 - */ -class DownloadResponse extends \OCP\AppFramework\Http\Response { - - private $filename; - private $contentType; - - /** - * Creates a response that prompts the user to download the file - * @param string $filename the name that the downloaded file should have - * @param string $contentType the mimetype that the downloaded file should have - * @since 7.0.0 - */ - public function __construct($filename, $contentType) { - $this->filename = $filename; - $this->contentType = $contentType; - - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); - $this->addHeader('Content-Type', $contentType); - } - - -} diff --git a/lib/public/appframework/http/emptycontentsecuritypolicy.php b/lib/public/appframework/http/emptycontentsecuritypolicy.php deleted file mode 100644 index 61718ff7c0e..00000000000 --- a/lib/public/appframework/http/emptycontentsecuritypolicy.php +++ /dev/null @@ -1,385 +0,0 @@ -<?php -/** - * @author Lukas Reschke <lukas@owncloud.com> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * Class EmptyContentSecurityPolicy is a simple helper which allows applications - * to modify the Content-Security-Policy sent by ownCloud. Per default the policy - * is forbidding everything. - * - * As alternative with sane exemptions look at ContentSecurityPolicy - * - * @see \OCP\AppFramework\Http\ContentSecurityPolicy - * @package OCP\AppFramework\Http - * @since 9.0.0 - */ -class EmptyContentSecurityPolicy { - /** @var bool Whether inline JS snippets are allowed */ - protected $inlineScriptAllowed = null; - /** - * @var bool Whether eval in JS scripts is allowed - * TODO: Disallow per default - * @link https://github.com/owncloud/core/issues/11925 - */ - protected $evalScriptAllowed = null; - /** @var array Domains from which scripts can get loaded */ - protected $allowedScriptDomains = null; - /** - * @var bool Whether inline CSS is allowed - * TODO: Disallow per default - * @link https://github.com/owncloud/core/issues/13458 - */ - protected $inlineStyleAllowed = null; - /** @var array Domains from which CSS can get loaded */ - protected $allowedStyleDomains = null; - /** @var array Domains from which images can get loaded */ - protected $allowedImageDomains = null; - /** @var array Domains to which connections can be done */ - protected $allowedConnectDomains = null; - /** @var array Domains from which media elements can be loaded */ - protected $allowedMediaDomains = null; - /** @var array Domains from which object elements can be loaded */ - protected $allowedObjectDomains = null; - /** @var array Domains from which iframes can be loaded */ - protected $allowedFrameDomains = null; - /** @var array Domains from which fonts can be loaded */ - protected $allowedFontDomains = null; - /** @var array Domains from which web-workers and nested browsing content can load elements */ - protected $allowedChildSrcDomains = null; - - /** - * Whether inline JavaScript snippets are allowed or forbidden - * @param bool $state - * @return $this - * @since 8.1.0 - */ - public function allowInlineScript($state = false) { - $this->inlineScriptAllowed = $state; - return $this; - } - - /** - * Whether eval in JavaScript is allowed or forbidden - * @param bool $state - * @return $this - * @since 8.1.0 - */ - public function allowEvalScript($state = true) { - $this->evalScriptAllowed = $state; - return $this; - } - - /** - * Allows to execute JavaScript files from a specific domain. Use * to - * allow JavaScript from all domains. - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedScriptDomain($domain) { - $this->allowedScriptDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed script domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowScriptDomain($domain) { - $this->allowedScriptDomains = array_diff($this->allowedScriptDomains, [$domain]); - return $this; - } - - /** - * Whether inline CSS snippets are allowed or forbidden - * @param bool $state - * @return $this - * @since 8.1.0 - */ - public function allowInlineStyle($state = true) { - $this->inlineStyleAllowed = $state; - return $this; - } - - /** - * Allows to execute CSS files from a specific domain. Use * to allow - * CSS from all domains. - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedStyleDomain($domain) { - $this->allowedStyleDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed style domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowStyleDomain($domain) { - $this->allowedStyleDomains = array_diff($this->allowedStyleDomains, [$domain]); - return $this; - } - - /** - * Allows using fonts from a specific domain. Use * to allow - * fonts from all domains. - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedFontDomain($domain) { - $this->allowedFontDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed font domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowFontDomain($domain) { - $this->allowedFontDomains = array_diff($this->allowedFontDomains, [$domain]); - return $this; - } - - /** - * Allows embedding images from a specific domain. Use * to allow - * images from all domains. - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedImageDomain($domain) { - $this->allowedImageDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed image domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowImageDomain($domain) { - $this->allowedImageDomains = array_diff($this->allowedImageDomains, [$domain]); - return $this; - } - - /** - * To which remote domains the JS connect to. - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedConnectDomain($domain) { - $this->allowedConnectDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed connect domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowConnectDomain($domain) { - $this->allowedConnectDomains = array_diff($this->allowedConnectDomains, [$domain]); - return $this; - } - - /** - * From which domains media elements can be embedded. - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedMediaDomain($domain) { - $this->allowedMediaDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed media domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowMediaDomain($domain) { - $this->allowedMediaDomains = array_diff($this->allowedMediaDomains, [$domain]); - return $this; - } - - /** - * From which domains objects such as <object>, <embed> or <applet> are executed - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedObjectDomain($domain) { - $this->allowedObjectDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed object domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowObjectDomain($domain) { - $this->allowedObjectDomains = array_diff($this->allowedObjectDomains, [$domain]); - return $this; - } - - /** - * Which domains can be embedded in an iframe - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedFrameDomain($domain) { - $this->allowedFrameDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed frame domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowFrameDomain($domain) { - $this->allowedFrameDomains = array_diff($this->allowedFrameDomains, [$domain]); - return $this; - } - - /** - * Domains from which web-workers and nested browsing content can load elements - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. - * @return $this - * @since 8.1.0 - */ - public function addAllowedChildSrcDomain($domain) { - $this->allowedChildSrcDomains[] = $domain; - return $this; - } - - /** - * Remove the specified allowed child src domain from the allowed domains. - * - * @param string $domain - * @return $this - * @since 8.1.0 - */ - public function disallowChildSrcDomain($domain) { - $this->allowedChildSrcDomains = array_diff($this->allowedChildSrcDomains, [$domain]); - return $this; - } - - /** - * Get the generated Content-Security-Policy as a string - * @return string - * @since 8.1.0 - */ - public function buildPolicy() { - $policy = "default-src 'none';"; - - if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { - $policy .= 'script-src '; - if(is_array($this->allowedScriptDomains)) { - $policy .= implode(' ', $this->allowedScriptDomains); - } - if($this->inlineScriptAllowed) { - $policy .= ' \'unsafe-inline\''; - } - if($this->evalScriptAllowed) { - $policy .= ' \'unsafe-eval\''; - } - $policy .= ';'; - } - - if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { - $policy .= 'style-src '; - if(is_array($this->allowedStyleDomains)) { - $policy .= implode(' ', $this->allowedStyleDomains); - } - if($this->inlineStyleAllowed) { - $policy .= ' \'unsafe-inline\''; - } - $policy .= ';'; - } - - if(!empty($this->allowedImageDomains)) { - $policy .= 'img-src ' . implode(' ', $this->allowedImageDomains); - $policy .= ';'; - } - - if(!empty($this->allowedFontDomains)) { - $policy .= 'font-src ' . implode(' ', $this->allowedFontDomains); - $policy .= ';'; - } - - if(!empty($this->allowedConnectDomains)) { - $policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains); - $policy .= ';'; - } - - if(!empty($this->allowedMediaDomains)) { - $policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains); - $policy .= ';'; - } - - if(!empty($this->allowedObjectDomains)) { - $policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains); - $policy .= ';'; - } - - if(!empty($this->allowedFrameDomains)) { - $policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains); - $policy .= ';'; - } - - if(!empty($this->allowedChildSrcDomains)) { - $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains); - $policy .= ';'; - } - - return rtrim($policy, ';'); - } -} diff --git a/lib/public/appframework/http/icallbackresponse.php b/lib/public/appframework/http/icallbackresponse.php deleted file mode 100644 index 97de484e917..00000000000 --- a/lib/public/appframework/http/icallbackresponse.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - - -/** - * Interface ICallbackResponse - * - * @package OCP\AppFramework\Http - * @since 8.1.0 - */ -interface ICallbackResponse { - - /** - * Outputs the content that should be printed - * - * @param IOutput $output a small wrapper that handles output - * @since 8.1.0 - */ - function callback(IOutput $output); - -} diff --git a/lib/public/appframework/http/ioutput.php b/lib/public/appframework/http/ioutput.php deleted file mode 100644 index f4ebc304bde..00000000000 --- a/lib/public/appframework/http/ioutput.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - - -/** - * Very thin wrapper class to make output testable - * @since 8.1.0 - */ -interface IOutput { - - /** - * @param string $out - * @since 8.1.0 - */ - public function setOutput($out); - - /** - * @param string $path - * - * @return bool false if an error occured - * @since 8.1.0 - */ - public function setReadfile($path); - - /** - * @param string $header - * @since 8.1.0 - */ - public function setHeader($header); - - /** - * @return int returns the current http response code - * @since 8.1.0 - */ - public function getHttpResponseCode(); - - /** - * @param int $code sets the http status code - * @since 8.1.0 - */ - public function setHttpResponseCode($code); - - /** - * @param string $name - * @param string $value - * @param int $expire - * @param string $path - * @param string $domain - * @param bool $secure - * @param bool $httpOnly - * @since 8.1.0 - */ - public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); - -} diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php deleted file mode 100644 index 89433fd23e5..00000000000 --- a/lib/public/appframework/http/jsonresponse.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Thomas Tanghus <thomas@tanghus.net> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -/** - * Public interface of ownCloud for apps to use. - * AppFramework\HTTP\JSONResponse class - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * A renderer for JSON calls - * @since 6.0.0 - */ -class JSONResponse extends Response { - - /** - * response data - * @var array|object - */ - protected $data; - - - /** - * constructor of JSONResponse - * @param array|object $data the object or array that should be transformed - * @param int $statusCode the Http status code, defaults to 200 - * @since 6.0.0 - */ - public function __construct($data=array(), $statusCode=Http::STATUS_OK) { - $this->data = $data; - $this->setStatus($statusCode); - $this->addHeader('Content-Type', 'application/json; charset=utf-8'); - } - - - /** - * Returns the rendered json - * @return string the rendered json - * @since 6.0.0 - * @throws \Exception If data could not get encoded - */ - public function render() { - $response = json_encode($this->data, JSON_HEX_TAG); - if($response === false) { - throw new \Exception(sprintf('Could not json_encode due to invalid ' . - 'non UTF-8 characters in the array: %s', var_export($this->data, true))); - } - - return $response; - } - - /** - * Sets values in the data json array - * @param array|object $data an array or object which will be transformed - * to JSON - * @return JSONResponse Reference to this object - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function setData($data){ - $this->data = $data; - - return $this; - } - - - /** - * Used to get the set parameters - * @return array the data - * @since 6.0.0 - */ - public function getData(){ - return $this->data; - } - -} diff --git a/lib/public/appframework/http/notfoundresponse.php b/lib/public/appframework/http/notfoundresponse.php deleted file mode 100644 index 8dcebd7cceb..00000000000 --- a/lib/public/appframework/http/notfoundresponse.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; -use OCP\Template; - -/** - * A generic 404 response showing an 404 error page as well to the end-user - * @since 8.1.0 - */ -class NotFoundResponse extends Response { - - /** - * @since 8.1.0 - */ - public function __construct() { - $this->setStatus(404); - } - - /** - * @return string - * @since 8.1.0 - */ - public function render() { - $template = new Template('core', '404', 'guest'); - return $template->fetchPage(); - } -} diff --git a/lib/public/appframework/http/ocsresponse.php b/lib/public/appframework/http/ocsresponse.php deleted file mode 100644 index da9de712c0a..00000000000 --- a/lib/public/appframework/http/ocsresponse.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -/** - * Public interface of ownCloud for apps to use. - * AppFramework\HTTP\JSONResponse class - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * A renderer for OCS responses - * @since 8.1.0 - */ -class OCSResponse extends Response { - - private $data; - private $format; - private $statuscode; - private $message; - private $itemscount; - private $itemsperpage; - - /** - * generates the xml or json response for the API call from an multidimenional data array. - * @param string $format - * @param int $statuscode - * @param string $message - * @param array $data - * @param int|string $itemscount - * @param int|string $itemsperpage - * @since 8.1.0 - */ - public function __construct($format, $statuscode, $message, - $data=[], $itemscount='', - $itemsperpage='') { - $this->format = $format; - $this->statuscode = $statuscode; - $this->message = $message; - $this->data = $data; - $this->itemscount = $itemscount; - $this->itemsperpage = $itemsperpage; - - // set the correct header based on the format parameter - if ($format === 'json') { - $this->addHeader( - 'Content-Type', 'application/json; charset=utf-8' - ); - } else { - $this->addHeader( - 'Content-Type', 'application/xml; charset=utf-8' - ); - } - } - - /** - * @return string - * @since 8.1.0 - */ - public function render() { - $r = new \OC_OCS_Result($this->data, $this->statuscode, $this->message); - $r->setTotalItems($this->itemscount); - $r->setItemsPerPage($this->itemsperpage); - - return \OC_API::renderResult($this->format, $r->getMeta(), $r->getData()); - } - - -} diff --git a/lib/public/appframework/http/redirectresponse.php b/lib/public/appframework/http/redirectresponse.php deleted file mode 100644 index 97140c9955f..00000000000 --- a/lib/public/appframework/http/redirectresponse.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author v1r0x <vinzenz.rosenkranz@gmail.com> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http\Response; -use OCP\AppFramework\Http; - - -/** - * Redirects to a different URL - * @since 7.0.0 - */ -class RedirectResponse extends Response { - - private $redirectURL; - - /** - * Creates a response that redirects to a url - * @param string $redirectURL the url to redirect to - * @since 7.0.0 - */ - public function __construct($redirectURL) { - $this->redirectURL = $redirectURL; - $this->setStatus(Http::STATUS_SEE_OTHER); - $this->addHeader('Location', $redirectURL); - } - - - /** - * @return string the url to redirect - * @since 7.0.0 - */ - public function getRedirectURL() { - return $this->redirectURL; - } - - -} diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php deleted file mode 100644 index 253d58b86ff..00000000000 --- a/lib/public/appframework/http/response.php +++ /dev/null @@ -1,326 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Thomas Tanghus <thomas@tanghus.net> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -/** - * Public interface of ownCloud for apps to use. - * AppFramework\HTTP\Response class - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * Base class for responses. Also used to just send headers. - * - * It handles headers, HTTP status code, last modified and ETag. - * @since 6.0.0 - */ -class Response { - - /** - * Headers - defaults to ['Cache-Control' => 'no-cache, must-revalidate'] - * @var array - */ - private $headers = array( - 'Cache-Control' => 'no-cache, must-revalidate' - ); - - - /** - * Cookies that will be need to be constructed as header - * @var array - */ - private $cookies = array(); - - - /** - * HTTP status code - defaults to STATUS OK - * @var int - */ - private $status = Http::STATUS_OK; - - - /** - * Last modified date - * @var \DateTime - */ - private $lastModified; - - - /** - * ETag - * @var string - */ - private $ETag; - - /** @var ContentSecurityPolicy|null Used Content-Security-Policy */ - private $contentSecurityPolicy = null; - - - /** - * Caches the response - * @param int $cacheSeconds the amount of seconds that should be cached - * if 0 then caching will be disabled - * @return $this - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function cacheFor($cacheSeconds) { - - if($cacheSeconds > 0) { - $this->addHeader('Cache-Control', 'max-age=' . $cacheSeconds . - ', must-revalidate'); - } else { - $this->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); - } - - return $this; - } - - /** - * Adds a new cookie to the response - * @param string $name The name of the cookie - * @param string $value The value of the cookie - * @param \DateTime|null $expireDate Date on that the cookie should expire, if set - * to null cookie will be considered as session - * cookie. - * @return $this - * @since 8.0.0 - */ - public function addCookie($name, $value, \DateTime $expireDate = null) { - $this->cookies[$name] = array('value' => $value, 'expireDate' => $expireDate); - return $this; - } - - - /** - * Set the specified cookies - * @param array $cookies array('foo' => array('value' => 'bar', 'expire' => null)) - * @return $this - * @since 8.0.0 - */ - public function setCookies(array $cookies) { - $this->cookies = $cookies; - return $this; - } - - - /** - * Invalidates the specified cookie - * @param string $name - * @return $this - * @since 8.0.0 - */ - public function invalidateCookie($name) { - $this->addCookie($name, 'expired', new \DateTime('1971-01-01 00:00')); - return $this; - } - - /** - * Invalidates the specified cookies - * @param array $cookieNames array('foo', 'bar') - * @return $this - * @since 8.0.0 - */ - public function invalidateCookies(array $cookieNames) { - foreach($cookieNames as $cookieName) { - $this->invalidateCookie($cookieName); - } - return $this; - } - - /** - * Returns the cookies - * @return array - * @since 8.0.0 - */ - public function getCookies() { - return $this->cookies; - } - - /** - * Adds a new header to the response that will be called before the render - * function - * @param string $name The name of the HTTP header - * @param string $value The value, null will delete it - * @return $this - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function addHeader($name, $value) { - $name = trim($name); // always remove leading and trailing whitespace - // to be able to reliably check for security - // headers - - if(is_null($value)) { - unset($this->headers[$name]); - } else { - $this->headers[$name] = $value; - } - - return $this; - } - - - /** - * Set the headers - * @param array $headers value header pairs - * @return $this - * @since 8.0.0 - */ - public function setHeaders(array $headers) { - $this->headers = $headers; - - return $this; - } - - - /** - * Returns the set headers - * @return array the headers - * @since 6.0.0 - */ - public function getHeaders() { - $mergeWith = []; - - if($this->lastModified) { - $mergeWith['Last-Modified'] = - $this->lastModified->format(\DateTime::RFC2822); - } - - // Build Content-Security-Policy and use default if none has been specified - if(is_null($this->contentSecurityPolicy)) { - $this->setContentSecurityPolicy(new ContentSecurityPolicy()); - } - $this->headers['Content-Security-Policy'] = $this->contentSecurityPolicy->buildPolicy(); - - if($this->ETag) { - $mergeWith['ETag'] = '"' . $this->ETag . '"'; - } - - return array_merge($mergeWith, $this->headers); - } - - - /** - * By default renders no output - * @return null - * @since 6.0.0 - */ - public function render() { - return null; - } - - - /** - * Set response status - * @param int $status a HTTP status code, see also the STATUS constants - * @return Response Reference to this object - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function setStatus($status) { - $this->status = $status; - - return $this; - } - - /** - * Set a Content-Security-Policy - * @param ContentSecurityPolicy $csp Policy to set for the response object - * @return $this - * @since 8.1.0 - */ - public function setContentSecurityPolicy(ContentSecurityPolicy $csp) { - $this->contentSecurityPolicy = $csp; - return $this; - } - - /** - * Get the currently used Content-Security-Policy - * @return ContentSecurityPolicy|null Used Content-Security-Policy or null if - * none specified. - * @since 8.1.0 - */ - public function getContentSecurityPolicy() { - return $this->contentSecurityPolicy; - } - - - /** - * Get response status - * @since 6.0.0 - */ - public function getStatus() { - return $this->status; - } - - - /** - * Get the ETag - * @return string the etag - * @since 6.0.0 - */ - public function getETag() { - return $this->ETag; - } - - - /** - * Get "last modified" date - * @return \DateTime RFC2822 formatted last modified date - * @since 6.0.0 - */ - public function getLastModified() { - return $this->lastModified; - } - - - /** - * Set the ETag - * @param string $ETag - * @return Response Reference to this object - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function setETag($ETag) { - $this->ETag = $ETag; - - return $this; - } - - - /** - * Set "last modified" date - * @param \DateTime $lastModified - * @return Response Reference to this object - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function setLastModified($lastModified) { - $this->lastModified = $lastModified; - - return $this; - } - - -} diff --git a/lib/public/appframework/http/streamresponse.php b/lib/public/appframework/http/streamresponse.php deleted file mode 100644 index e9157f9ddb2..00000000000 --- a/lib/public/appframework/http/streamresponse.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCP\AppFramework\Http; - -use OCP\AppFramework\Http; - -/** - * Class StreamResponse - * - * @package OCP\AppFramework\Http - * @since 8.1.0 - */ -class StreamResponse extends Response implements ICallbackResponse { - /** @var string */ - private $filePath; - - /** - * @param string $filePath the path to the file which should be streamed - * @since 8.1.0 - */ - public function __construct ($filePath) { - $this->filePath = $filePath; - } - - - /** - * Streams the file using readfile - * - * @param IOutput $output a small wrapper that handles output - * @since 8.1.0 - */ - public function callback (IOutput $output) { - // handle caching - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { - if (!file_exists($this->filePath)) { - $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); - } elseif ($output->setReadfile($this->filePath) === false) { - $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); - } - } - } - -} diff --git a/lib/public/appframework/http/templateresponse.php b/lib/public/appframework/http/templateresponse.php deleted file mode 100644 index 7774d881e4d..00000000000 --- a/lib/public/appframework/http/templateresponse.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Thomas Tanghus <thomas@tanghus.net> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -/** - * Public interface of ownCloud for apps to use. - * AppFramework\HTTP\TemplateResponse class - */ - -namespace OCP\AppFramework\Http; - - -/** - * Response for a normal template - * @since 6.0.0 - */ -class TemplateResponse extends Response { - - /** - * name of the template - * @var string - */ - protected $templateName; - - /** - * parameters - * @var array - */ - protected $params; - - /** - * rendering type (admin, user, blank) - * @var string - */ - protected $renderAs; - - /** - * app name - * @var string - */ - protected $appName; - - /** - * constructor of TemplateResponse - * @param string $appName the name of the app to load the template from - * @param string $templateName the name of the template - * @param array $params an array of parameters which should be passed to the - * template - * @param string $renderAs how the page should be rendered, defaults to user - * @since 6.0.0 - parameters $params and $renderAs were added in 7.0.0 - */ - public function __construct($appName, $templateName, array $params=array(), - $renderAs='user') { - $this->templateName = $templateName; - $this->appName = $appName; - $this->params = $params; - $this->renderAs = $renderAs; - } - - - /** - * Sets template parameters - * @param array $params an array with key => value structure which sets template - * variables - * @return TemplateResponse Reference to this object - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function setParams(array $params){ - $this->params = $params; - - return $this; - } - - - /** - * Used for accessing the set parameters - * @return array the params - * @since 6.0.0 - */ - public function getParams(){ - return $this->params; - } - - - /** - * Used for accessing the name of the set template - * @return string the name of the used template - * @since 6.0.0 - */ - public function getTemplateName(){ - return $this->templateName; - } - - - /** - * Sets the template page - * @param string $renderAs admin, user or blank. Admin also prints the admin - * settings header and footer, user renders the normal - * normal page including footer and header and blank - * just renders the plain template - * @return TemplateResponse Reference to this object - * @since 6.0.0 - return value was added in 7.0.0 - */ - public function renderAs($renderAs){ - $this->renderAs = $renderAs; - - return $this; - } - - - /** - * Returns the set renderAs - * @return string the renderAs value - * @since 6.0.0 - */ - public function getRenderAs(){ - return $this->renderAs; - } - - - /** - * Returns the rendered html - * @return string the rendered html - * @since 6.0.0 - */ - public function render(){ - // \OCP\Template needs an empty string instead of 'blank' for an unwrapped response - $renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs; - - $template = new \OCP\Template($this->appName, $this->templateName, $renderAs); - - foreach($this->params as $key => $value){ - $template->assign($key, $value); - } - - return $template->fetchPage(); - } - -} |