Select Git revision
.scrutinizer.yml
helper.php 16.99 KiB
<?php
/**
* ownCloud
*
* @author Frank Karlitschek
* @author Jakob Sack
* @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/>.
*
*/
/**
* Collection of useful functions
*/
class OC_Helper {
private static $mimetypes=array();
private static $tmpFiles=array();
/**
* @brief Creates an url
* @param $app app
* @param $file file
* @returns the url
*
* Returns a url to the given app and file.
*/
public static function linkTo( $app, $file ){
if( $app != '' ){
$app .= '/';
// Check if the app is in the app folder
if( file_exists( OC::$APPSROOT . '/apps/'. $app.$file )){
if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){
if(substr($app, -1, 1) == '/'){
$app = substr($app, 0, strlen($app) - 1);
}
$urlLinkTo = OC::$WEBROOT . '/?app=' . $app;
$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
}else{
$urlLinkTo = OC::$APPSWEBROOT . '/apps/' . $app . $file;
}
}
else{
$urlLinkTo = OC::$WEBROOT . '/' . $app . $file;
}
}
else{
if( file_exists( OC::$SERVERROOT . '/core/'. $file )){
$urlLinkTo = OC::$WEBROOT . '/core/'.$file;
}
else{
$urlLinkTo = OC::$WEBROOT . '/'.$file;
}
}
return $urlLinkTo;
}
/**