aboutsummaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorJakob Sack <kde@jakobsack.de>2011-03-02 22:18:22 +0100
committerJakob Sack <kde@jakobsack.de>2011-03-02 22:18:22 +0100
commitdfa6b749baf95856601ea476e58f884cfb453055 (patch)
treea91f7ebabb9c684996824fa1a97f4e266e73be83 /lib/helper.php
parentede34c17dd04fcc13ce7870947fc66aba1ece274 (diff)
downloadnextcloud-server-dfa6b749baf95856601ea476e58f884cfb453055.tar.gz
nextcloud-server-dfa6b749baf95856601ea476e58f884cfb453055.zip
Introducing OC_HELPER for small helper functions; making setup of filesystem optional
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
new file mode 100644
index 00000000000..085ab67e737
--- /dev/null
+++ b/lib/helper.php
@@ -0,0 +1,84 @@
+<?php
+/**
+* ownCloud
+*
+* @author Frank Karlitschek
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+
+/**
+ * Class for utility functions
+ *
+ */
+class OC_HELPER {
+ /**
+ * Create an url
+ *
+ * @param string $application
+ * @param string $file
+ */
+ public static function linkTo( $application, $file = null ){
+ global $WEBROOT;
+ if( is_null( $file )){
+ $file = $application;
+ $application = "";
+ }
+ return "$WEBROOT/$application/$file";
+ }
+
+ /**
+ * Create an image link
+ *
+ * @param string $application
+ * @param string $file
+ */
+ public static function imagePath( $application, $file = null ){
+ global $WEBROOT;
+ if( is_null( $file )){
+ $file = $application;
+ $application = "";
+ }
+ return "$WEBROOT/$application/img/$file";
+ }
+
+ /**
+ * show an icon for a filetype
+ *
+ */
+ public static function showIcon( $mimetype ){
+ global $SERVERROOT;
+ global $WEBROOT;
+ // Replace slash with a minus
+ $mimetype = str_replace( "/", "-", $mimetype );
+
+ // Is it a dir?
+ if( $mimetype == "dir" ){
+ return "$WEBROOT/img/places/folder.png";
+ }
+
+ // Icon exists?
+ if( file_exists( "$SERVERROOT/img/mimetypes/$mimetype.png" )){
+ return "$WEBROOT/img/mimetypes/$mimetype.png";
+ }
+ else{
+ return "$WEBROOT/img/mimetypes/application-octet-stream.png";
+ }
+ }
+}
+
+?>