aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Extension.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-12-04 20:41:01 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-12-04 20:41:01 +0100
commitf9b037742a0aeb49cab86782d1a59913c2de47bf (patch)
tree7b781210f8dfd3e306d118349fd08ada74f7d2af /lib/Minz/Extension.php
parent0316badf649ef285f068847ef094ace80dd51290 (diff)
Update ext.php to serve any file from extensions
Add an extension->getFileUrl() method to facilitate url generation
Diffstat (limited to 'lib/Minz/Extension.php')
-rw-r--r--lib/Minz/Extension.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php
index f442344a3..72a375a6d 100644
--- a/lib/Minz/Extension.php
+++ b/lib/Minz/Extension.php
@@ -75,6 +75,9 @@ class Minz_Extension {
public function getEntrypoint() {
return $this->entrypoint;
}
+ public function getPath() {
+ return $this->path;
+ }
public function getAuthor() {
return $this->author;
}
@@ -93,4 +96,24 @@ class Minz_Extension {
}
$this->type = $type;
}
+
+ /**
+ * Return the url for a given file.
+ *
+ * @param $filename name of the file to serve.
+ * @param $type the type (js or css) of the file to serve.
+ * @return the url corresponding to the file.
+ */
+ public function getFileUrl($filename, $type) {
+ $dir = end(explode('/', $this->path));
+ $file_name_url = urlencode($dir . '/' . $filename);
+
+ $absolute_path = $this->path . '/' . $filename;
+ $mtime = @filemtime($absolute_path);
+
+ $url = '/ext.php?f=' . $file_name_url .
+ '&amp;t=' . $type .
+ '&amp;' . $mtime;
+ return Minz_Url::display($url);
+ }
}