Commit 878fe681 authored by Sigrid Suski's avatar Sigrid Suski

(+) Implementation of FileSystem::FixUrl and failsafe for FileSystem::FixPath

	Framework version 1.0.9
parent dd8b6c87
......@@ -7,7 +7,7 @@
* Email: sobi[at]sigsiu.net
* Url: https://www.Sigsiu.NET
*
* @copyright Copyright (C) 2006 - 2017 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @copyright Copyright (C) 2006 - 2019 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
......@@ -43,5 +43,5 @@ abstract class C
const NO = 0;
const ROOT = JPATH_ROOT;
const DS = DIRECTORY_SEPARATOR;
const VERSION = '1.0.8';
const VERSION = '1.0.9';
}
......@@ -29,6 +29,7 @@ abstract class FileSystem
/**
**
* @param string $file
*
* @return bool
*/
public static function Exists( $file )
......@@ -40,6 +41,7 @@ abstract class FileSystem
* *
* @param string $file
* @param bool $safe
*
* @return bool
*/
public static function Clean( $file, $safe = false )
......@@ -56,28 +58,33 @@ abstract class FileSystem
$file = str_replace( '//', '/', $file );
}
}
return $file;
}
/**
* *
* @param string $file
*
* @return bool
*/
public static function GetExt( $file )
{
$ext = explode( ".", $file );
return $ext[ count( $ext ) - 1 ];
}
/**
* *
* @param string $file
*
* @return bool
*/
public static function GetFileName( $file )
{
$ext = explode( '/', $file );
return $ext[ count( $ext ) - 1 ];
}
......@@ -85,6 +92,7 @@ abstract class FileSystem
* *
* @param string $source
* @param string $destination
*
* @return bool
*/
public static function Copy( $source, $destination )
......@@ -96,7 +104,7 @@ abstract class FileSystem
/** clean the path */
/** @noinspection PhpExpressionResultUnusedInspection */
for ( $i; $i != 0; $i-- ) {
if( isset( $path[ $i ] ) && !( $path[ $i ] ) ) {
if ( isset( $path[ $i ] ) && !( $path[ $i ] ) ) {
unset( $path[ $i ] );
}
}
......@@ -120,6 +128,7 @@ abstract class FileSystem
/**
* *
* @param string $file
*
* @throws Exception
* @return bool
*/
......@@ -130,6 +139,7 @@ abstract class FileSystem
if ( $file == C::ROOT || dirname( $file ) == C::ROOT ) {
throw new Exception( Framework::Txt( 'Fatal error. Trying to delete not allowed path "%s"', $file ) );
}
return \Jfolder::delete( $file );
}
else {
......@@ -141,6 +151,7 @@ abstract class FileSystem
* *
* @param string $source
* @param string $destination
*
* @return bool
*/
public static function Move( $source, $destination )
......@@ -151,6 +162,7 @@ abstract class FileSystem
/**
* *
* @param string $file
*
* @return bool
*/
public static function Read( $file )
......@@ -160,13 +172,31 @@ abstract class FileSystem
public static function FixPath( $path )
{
$sep = explode( '://', $path );
if ( is_array( $sep ) && isset( $sep[ 1 ] ) ) {
return self::FixUrl( $path );
}
// remove double and triple slashes
return str_replace( C::DS . C::DS, C::DS, str_replace( C::DS . C::DS, C::DS, str_replace( '\\', '/', $path ) ) );
}
public static function FixUrl( $url )
{
$sep = explode( '://', $url );
if ( is_array( $sep ) && isset( $sep[ 1 ] ) ) {
return $sep[ 0 ] . '://' . str_replace( C::DS . C::DS, C::DS, str_replace( C::DS . C::DS, C::DS, str_replace( '\\', '/', $sep[ 1 ] ) ) );
}
return self::FixPath( $url );
}
/**
* @param string $file
* @param string $buffer
* @param bool $append
*
* @throws Exception
* @return bool
*/
......@@ -188,6 +218,7 @@ abstract class FileSystem
/**
* @param string $name
* @param string $destination
*
* @return bool
*/
public static function Upload( $name, $destination )
......@@ -201,12 +232,14 @@ abstract class FileSystem
if ( strstr( $name, str_replace( '\\', '/', SOBI_PATH ) ) ) {
return self::Move( $name, $destination );
}
return \Jfile::upload( $name, $destination, false, true );
}
/**
* @param string $path
* @param string $hex
*
* @return bool
*/
public static function Chmod( $path, $hex )
......@@ -217,6 +250,7 @@ abstract class FileSystem
/**
* @param string $path
* @param int $mode
*
* @throws Exception
* @return bool
*/
......@@ -234,6 +268,7 @@ abstract class FileSystem
/**
* *
* @param string $path
*
* @return bool
*/
public static function Rmdir( $path )
......@@ -244,6 +279,7 @@ abstract class FileSystem
/**
* *
* @param string $path
*
* @return bool
*/
public static function Readable( $path )
......@@ -254,6 +290,7 @@ abstract class FileSystem
/**
* *
* @param string $path
*
* @return bool
*/
public static function Writable( $path )
......@@ -264,6 +301,7 @@ abstract class FileSystem
/**
* *
* @param string $path
*
* @return bool
*/
public static function Owner( $path )
......@@ -275,6 +313,7 @@ abstract class FileSystem
* *
* @param string $source
* @param string $destination
*
* @return bool
*/
public static function Rename( $source, $destination )
......
......@@ -30,6 +30,8 @@ Legend:
1.0.9 ()
------------------
(+) Implementation of FileSystem::FixUrl and failsafe for FileSystem::FixPath
(#) Image Rotation does not work correctly
(#) Original file should not be deleted after resampling
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment