Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/apps.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-11-28 04:30:18 +0400
committerBernhard Posselt <nukeawhale@gmail.com>2012-11-28 04:30:18 +0400
commitba8ab5f360e1a9ec215b71d612b02152b55fef5c (patch)
tree1eeafdfe2fa2d3adf7fd57604cd330b479608eaa /apptemplate
parenta8c658878bbaab26d975bb043ab7258c10df9e1f (diff)
spaces to tabs
Diffstat (limited to 'apptemplate')
-rw-r--r--apptemplate/lib/response.php226
1 files changed, 113 insertions, 113 deletions
diff --git a/apptemplate/lib/response.php b/apptemplate/lib/response.php
index 2038fc27f..90e4b1b3c 100644
--- a/apptemplate/lib/response.php
+++ b/apptemplate/lib/response.php
@@ -25,7 +25,7 @@
namespace OCA\AppTemplate;
interface Response {
- function render();
+ function render();
}
/**
@@ -33,62 +33,62 @@ interface Response {
*/
class TemplateResponse implements Response {
- private $templateName;
- private $params;
- private $appName;
- private $renderAs;
-
- /**
- * @param string $appName: the name of your app
- * @param string $templateName: the name of the template
- */
- public function __construct($appName, $templateName) {
- $this->templateName = $templateName;
- $this->appName = $appName;
- $this->params = array();
- $this->renderAs = 'user';
- }
-
-
- /**
- * @brief sets template parameters
- * @param array $params: an array with key => value structure which sets template
- * variables
- */
- public function setParams($params){
- $this->params = $params;
- }
-
-
- /**
- * @brief sets the template page
- * @param string $renderAs: admin, user or blank: admin renders the page on
- * the admin settings page, user renders a normal
- * owncloud page, blank renders the template alone
- */
- public function renderAs($renderAs='user'){
- $this->renderAs = $renderAs;
- }
-
-
- /**
- * Returns the rendered html
- * @return the rendered html
- */
- public function render(){
- if($this->renderAs === 'blank'){
- $template = new \OCP\Template($this->appName, $this->templateName);
- } else {
- $template = new \OCP\Template($this->appName, $this->templateName,
- $this->renderAs);
- }
-
- foreach($this->params as $key => $value){
- $template->assign($key, $value, false);
- }
-
- return $template->fetchPage();
- }
+ private $templateName;
+ private $params;
+ private $appName;
+ private $renderAs;
+
+ /**
+ * @param string $appName: the name of your app
+ * @param string $templateName: the name of the template
+ */
+ public function __construct($appName, $templateName) {
+ $this->templateName = $templateName;
+ $this->appName = $appName;
+ $this->params = array();
+ $this->renderAs = 'user';
+ }
+
+
+ /**
+ * @brief sets template parameters
+ * @param array $params: an array with key => value structure which sets template
+ * variables
+ */
+ public function setParams($params){
+ $this->params = $params;
+ }
+
+
+ /**
+ * @brief sets the template page
+ * @param string $renderAs: admin, user or blank: admin renders the page on
+ * the admin settings page, user renders a normal
+ * owncloud page, blank renders the template alone
+ */
+ public function renderAs($renderAs='user'){
+ $this->renderAs = $renderAs;
+ }
+
+
+ /**
+ * Returns the rendered html
+ * @return the rendered html
+ */
+ public function render(){
+ if($this->renderAs === 'blank'){
+ $template = new \OCP\Template($this->appName, $this->templateName);
+ } else {
+ $template = new \OCP\Template($this->appName, $this->templateName,
+ $this->renderAs);
+ }
+
+ foreach($this->params as $key => $value){
+ $template->assign($key, $value, false);
+ }
+
+ return $template->fetchPage();
+ }
}
@@ -98,61 +98,61 @@ class TemplateResponse implements Response {
*/
class JSONResponse implements Response {
- private $name;
- private $data;
- private $appName;
-
- /**
- * @param string $appName: the name of your app
- */
- public function __construct($appName) {
- $this->appName = $appName;
- $this->data = array();
- $this->error = false;
- }
-
- /**
- * @brief sets values in the data json array
- * @param array $params: an array with key => value structure which will be
- * transformed to JSON
- */
- public function setParams($params){
- $this->data['data'] = $params;
- }
-
-
- /**
- * @brief in case we want to render an error message, also logs into the
- * owncloud log
- * @param string $message: the error message
- * @param string $file: the file where the error occured, use __FILE__ in
- * the file where you call it
- */
- public function setErrorMessage($msg, $file){
- $this->error = true;
- $this->data['msg'] = $msg;
- \OCP\Util::writeLog($this->appName, $file . ': ' . $msg, \OCP\Util::ERROR);
- }
-
-
- /**
- * Returns the rendered json
- * @return the rendered json
- */
- public function render(){
-
- ob_start();
-
- if($this->error){
- \OCP\JSON::error($this->data);
- } else {
- \OCP\JSON::success($this->data);
- }
-
- $result = ob_get_contents();
- ob_end_clean();
-
- return $result;
- }
+ private $name;
+ private $data;
+ private $appName;
+
+ /**
+ * @param string $appName: the name of your app
+ */
+ public function __construct($appName) {
+ $this->appName = $appName;
+ $this->data = array();
+ $this->error = false;
+ }
+
+ /**
+ * @brief sets values in the data json array
+ * @param array $params: an array with key => value structure which will be
+ * transformed to JSON
+ */
+ public function setParams($params){
+ $this->data['data'] = $params;
+ }
+
+
+ /**
+ * @brief in case we want to render an error message, also logs into the
+ * owncloud log
+ * @param string $message: the error message
+ * @param string $file: the file where the error occured, use __FILE__ in
+ * the file where you call it
+ */
+ public function setErrorMessage($msg, $file){
+ $this->error = true;
+ $this->data['msg'] = $msg;
+ \OCP\Util::writeLog($this->appName, $file . ': ' . $msg, \OCP\Util::ERROR);
+ }
+
+
+ /**
+ * Returns the rendered json
+ * @return the rendered json
+ */
+ public function render(){
+
+ ob_start();
+
+ if($this->error){
+ \OCP\JSON::error($this->data);
+ } else {
+ \OCP\JSON::success($this->data);
+ }
+
+ $result = ob_get_contents();
+ ob_end_clean();
+
+ return $result;
+ }
} \ No newline at end of file