Skip to content
Snippets Groups Projects
Select Git revision
  • 5caa7576d493ef6b639b59718701d67bf8db90cb
  • master default protected
2 results

router.php

Blame
  • helper.php 19.53 KiB
    <?php
    /**
     * ownCloud
     *
     * @author Frank Karlitschek
     * @author Jakob Sack
     * @copyright 2012 Frank Karlitschek frank@owncloud.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_path = OC_App::getAppPath($app);
    			// Check if the app is in the app folder
    			if( $app_path && file_exists( $app_path.'/'.$file )){
    				if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){
    					$urlLinkTo =  OC::$WEBROOT . '/?app=' . $app;
    					$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
    				}else{
    					$urlLinkTo =  OC_App::getAppWebPath($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;
    	}
    
    	/**
    	 * @brief Returns the server host
    	 * @returns the server host
    	 *