summaryrefslogtreecommitdiffstats
path: root/lib/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-08-07 16:53:09 +0200
committerRobin Appelman <icewind@owncloud.com>2013-08-07 16:53:09 +0200
commit9321eceed6a94f74ccdb908c05e97dfb1585d211 (patch)
tree1bf5a557c92a527b2b0017ec22329621ead2e486 /lib/files
parentfc332acf8a8ecff6cebd929a24e008648138a46d (diff)
downloadnextcloud-server-9321eceed6a94f74ccdb908c05e97dfb1585d211.tar.gz
nextcloud-server-9321eceed6a94f74ccdb908c05e97dfb1585d211.zip
add the option to have templates for newly created files
Diffstat (limited to 'lib/files')
-rw-r--r--lib/files/type/templatemanager.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/files/type/templatemanager.php b/lib/files/type/templatemanager.php
new file mode 100644
index 00000000000..cd1536d2732
--- /dev/null
+++ b/lib/files/type/templatemanager.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Type;
+
+class TemplateManager {
+ protected $templates = array();
+
+ public function registerTemplate($mimetype, $path) {
+ $this->templates[$mimetype] = $path;
+ }
+
+ /**
+ * get the path of the template for a mimetype
+ *
+ * @param string $mimetype
+ * @return string | null
+ */
+ public function getTemplatePath($mimetype) {
+ if (isset($this->templates[$mimetype])) {
+ return $this->templates[$mimetype];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * get the template content for a mimetype
+ *
+ * @param string $mimetype
+ * @return string
+ */
+ public function getTemplate($mimetype) {
+ $path = $this->getTemplatePath($mimetype);
+ if ($path) {
+ return file_get_contents($path);
+ } else {
+ return '';
+ }
+ }
+}