mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-16 20:08:41 +00:00
Merge remote-tracking branch 'refs/remotes/origin/develop' into documentation
# Conflicts: # System/File/Local/File.php
This commit is contained in:
commit
51a016d228
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
namespace phpOMS\DataStorage\Cache;
|
||||
|
||||
use phpOMS\System\File\Directory;
|
||||
use phpOMS\System\File\Local\Directory;
|
||||
|
||||
/**
|
||||
* MemCache class.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ namespace phpOMS\DataStorage\Database\Query;
|
|||
|
||||
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||
use phpOMS\DataStorage\Database\Query;
|
||||
|
||||
/**
|
||||
* Database query builder.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
namespace phpOMS\Log;
|
||||
|
||||
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
||||
use phpOMS\System\File\File;
|
||||
use phpOMS\System\File\Local\File;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\Utils\StringUtils;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace phpOMS\Module;
|
|||
|
||||
use phpOMS\DataStorage\Database\DatabaseType;
|
||||
use phpOMS\DataStorage\Database\Pool;
|
||||
use phpOMS\System\File\Directory;
|
||||
use phpOMS\System\File\Local\Directory;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\System\File\PermissionException;
|
||||
use phpOMS\Utils\Parser\Php\ArrayParser;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class ModuleManager
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
const MODULE_PATH = ROOT_PATH . DIRECTORY_SEPARATOR . 'Modules';
|
||||
const MODULE_PATH = __DIR__ . '/../../Modules';
|
||||
|
||||
/**
|
||||
* All modules that are running on this uri.
|
||||
|
|
|
|||
82
System/File/ContainerInterface.php
Normal file
82
System/File/ContainerInterface.php
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
*
|
||||
* Performing operations on the file system
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\System\File
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface ContainerInterface
|
||||
{
|
||||
public static function created(string $path) : \DateTime;
|
||||
|
||||
public static function changed(string $path) : \DateTime;
|
||||
|
||||
public static function owner(string $path) : int;
|
||||
|
||||
public static function permission(string $path) : int;
|
||||
|
||||
public static function parent(string $path) : string;
|
||||
|
||||
public static function create(string $path) : bool;
|
||||
|
||||
public static function delete(string $path) : bool;
|
||||
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool;
|
||||
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool;
|
||||
|
||||
public static function size(string $path) : int;
|
||||
|
||||
public static function exists(string $path) : bool;
|
||||
|
||||
public function getCount() : int;
|
||||
|
||||
public function getSize() : int;
|
||||
|
||||
public function getName() : string;
|
||||
|
||||
public function getPath() : string;
|
||||
|
||||
public function getParent() : FileInterface;
|
||||
|
||||
public function createNode() : bool;
|
||||
|
||||
public function copyNode() : bool;
|
||||
|
||||
public function moveNode() : bool;
|
||||
|
||||
public function deleteNode() : bool;
|
||||
|
||||
public function getCreatedAt() : \DateTime;
|
||||
|
||||
public function getChangedAt() : \DateTime;
|
||||
|
||||
public function getOwner() : int;
|
||||
|
||||
public function getPermission() : string;
|
||||
|
||||
public function index();
|
||||
}
|
||||
|
|
@ -28,7 +28,6 @@ namespace phpOMS\System\File;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class NullFile extends File
|
||||
interface DirectoryInterface extends ContainerInterface, \Iterator, \ArrayAccess
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -28,63 +28,14 @@ namespace phpOMS\System\File;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface FileInterface
|
||||
interface FileInterface extends ContainerInterface
|
||||
{
|
||||
public static function created(string $path) : \DateTime;
|
||||
|
||||
public static function changed(string $path) : \DateTime;
|
||||
|
||||
public static function owner(string $path) : int;
|
||||
|
||||
public static function permission(string $path) : int;
|
||||
|
||||
public static function parent(string $path) : string;
|
||||
|
||||
public static function create(string $path) : bool;
|
||||
|
||||
public static function delete(string $path) : bool;
|
||||
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool;
|
||||
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool;
|
||||
|
||||
public static function put(string $path, string $content, bool $overwrite = true) : bool;
|
||||
|
||||
public static function get(string $path) : string;
|
||||
|
||||
public static function size(string $path) : int;
|
||||
|
||||
public static function exists(string $path) : bool;
|
||||
|
||||
public function getCount() : int;
|
||||
|
||||
public function getSize() : int;
|
||||
|
||||
public function getName() : string;
|
||||
|
||||
public function getPath() : string;
|
||||
|
||||
public function getParent() : FileInterface;
|
||||
|
||||
public function createNode() : bool;
|
||||
|
||||
public function copyNode() : bool;
|
||||
|
||||
public function moveNode() : bool;
|
||||
|
||||
public function deleteNode() : bool;
|
||||
|
||||
public function putContent() : bool;
|
||||
|
||||
public function getContent() : string;
|
||||
|
||||
public function getCreatedAt() : \DateTime;
|
||||
|
||||
public function getChangedAt() : \DateTime;
|
||||
|
||||
public function getOwner() : int;
|
||||
|
||||
public function getPermission() : string;
|
||||
|
||||
public function index();
|
||||
}
|
||||
|
|
|
|||
0
System/File/Ftp/FtpStorage.php
Normal file
0
System/File/Ftp/FtpStorage.php
Normal file
|
|
@ -13,8 +13,10 @@
|
|||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
namespace phpOMS\System\File\Local;
|
||||
|
||||
use phpOMS\System\File\DirectoryInterface;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\Utils\StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -30,10 +32,10 @@ use phpOMS\Utils\StringUtils;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
||||
class Directory extends FileAbstract implements DirectoryInterface
|
||||
{
|
||||
/**
|
||||
* Direcotry list filter.
|
||||
* Directory list filter.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
|
|
@ -41,7 +43,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
|||
private $filter = '*';
|
||||
|
||||
/**
|
||||
* Direcotry nodes (files and directories).
|
||||
* Directory nodes (files and directories).
|
||||
*
|
||||
* @var FileAbstract[]
|
||||
* @since 1.0.0
|
||||
|
|
@ -189,7 +191,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function deletePath($path) : bool
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
$path = realpath($oldPath = $path);
|
||||
if ($path === false || !is_dir($path) || StringUtils::startsWith($path, ROOT_PATH)) {
|
||||
|
|
@ -204,7 +206,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
|||
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file)) {
|
||||
self::deletePath($file);
|
||||
self::delete($file);
|
||||
} else {
|
||||
unlink($file);
|
||||
}
|
||||
|
|
@ -255,11 +257,6 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
|||
|
||||
/* Iterator */
|
||||
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
// TODO: Implement delete() method.
|
||||
}
|
||||
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copy() method.
|
||||
|
|
@ -13,7 +13,9 @@
|
|||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
namespace phpOMS\System\File\Local;
|
||||
use phpOMS\System\File\FileInterface;
|
||||
use phpOMS\System\File\PathException;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
|
|
@ -28,7 +30,7 @@ namespace phpOMS\System\File;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class File extends FileAbstract
|
||||
class File extends FileAbstract implements FileInterface
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -68,20 +70,20 @@ class File extends FileAbstract
|
|||
* Save string to file.
|
||||
*
|
||||
* If the directory doesn't exist where the string should be saved it will be created
|
||||
* as well as potential parent directories. The directories will be created with '0644'
|
||||
* as well as potential subdirectories. The directories will be created with '0644'
|
||||
* permission.
|
||||
*
|
||||
* @param string $path Path to save the string to
|
||||
* @param string $content Content to save to file
|
||||
* @param bool $overwrite Should the file be overwritten if it already exists
|
||||
* @param string $path Path to save the string to
|
||||
* @param string $content Content to save to file
|
||||
* @param bool $overwrite Should the file be overwritten if it already exists
|
||||
*
|
||||
* @example File::put('/var/www/html/test.txt', 'string'); // true
|
||||
* @example File::put('/var/www/html/test.txt', 'string', false); // false
|
||||
*
|
||||
* @return bool Returns true on successful file write and false on failure
|
||||
* @return bool Returns true on successfule file write and false on failure
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function put(string $path, string $content, bool $overwrite = true) : bool
|
||||
{
|
||||
|
|
@ -109,8 +111,8 @@ class File extends FileAbstract
|
|||
*
|
||||
* @throws PathException In case the file doesn't exist this exception gets thrown.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function get(string $path) : string
|
||||
{
|
||||
|
|
@ -130,8 +132,8 @@ class File extends FileAbstract
|
|||
*
|
||||
* @return bool Returns true if the file exists and false if it doesn't.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function exists(string $path) : bool
|
||||
{
|
||||
|
|
@ -147,8 +149,8 @@ class File extends FileAbstract
|
|||
*
|
||||
* @return string Returns the parent full directory path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function parent(string $path) : string
|
||||
{
|
||||
|
|
@ -166,8 +168,8 @@ class File extends FileAbstract
|
|||
*
|
||||
* @example File::created('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function created(string $path) : \DateTime
|
||||
{
|
||||
|
|
@ -192,8 +194,8 @@ class File extends FileAbstract
|
|||
*
|
||||
* @example File::changed('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function changed(string $path) : \DateTime
|
||||
{
|
||||
|
|
@ -207,18 +209,6 @@ class File extends FileAbstract
|
|||
return $changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of a file.
|
||||
*
|
||||
* @param string $path Path of the file to get the size for.
|
||||
*
|
||||
* @return int Returns the size of a file
|
||||
*
|
||||
* @example File::size('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function size(string $path) : int
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
|
|
@ -228,18 +218,6 @@ class File extends FileAbstract
|
|||
return filesize($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner of a file.
|
||||
*
|
||||
* @param string $path Path of the file to get owner for.
|
||||
*
|
||||
* @return int Returns the owner of a file.
|
||||
*
|
||||
* @example File::owner('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function owner(string $path) : int
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
|
|
@ -249,18 +227,6 @@ class File extends FileAbstract
|
|||
return fileowner($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permission of a file.
|
||||
*
|
||||
* @param string $path Path of the file to get the permission for.
|
||||
*
|
||||
* @return int Returns the permission of a file <owner><group><all>
|
||||
*
|
||||
* @example File::size('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function permission(string $path) : int
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
|
|
@ -270,61 +236,11 @@ class File extends FileAbstract
|
|||
return fileperms($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory name of a file.
|
||||
*
|
||||
* @param string $path Path of the file to get the directory name for.
|
||||
*
|
||||
* @return string Returns the directory name of a file.
|
||||
*
|
||||
* @example File::size('/var/www/html/test.txt'); // html
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function dirname(string $path) : string
|
||||
{
|
||||
return basename(dirname($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory path of a file.
|
||||
*
|
||||
* @param string $path Path of the file to get the directory path for.
|
||||
*
|
||||
* @return string Returns the directory path of a file.
|
||||
*
|
||||
* @example File::size('/var/www/html/test.txt'); // /var/www/html
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function dirpath(string $path) : string
|
||||
{
|
||||
return dirname($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a file.
|
||||
*
|
||||
* If the directory doesn't exist where the file should be copied to it will be created
|
||||
* as well as potential parent directories. The directories will be created with '0644'
|
||||
* permission.
|
||||
*
|
||||
* @param string $from The path of the file to copy.
|
||||
* @param string $to The path and name of the file where to save the copy.
|
||||
* @param bool $overwrite Should the file be overwritten if it already exists
|
||||
*
|
||||
* @example File::copy('/var/www/html/test.txt', '/var/www/html/test2.txt'); // true
|
||||
* @example File::copy('/var/www/html/test.txt', '/var/www/html/test2.txt'); // false
|
||||
*
|
||||
* @return bool Returns true on successful file copy and false on failure
|
||||
*
|
||||
* @throws PathException Throws this exception if the file to copy doesn't exist.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
if (!file_exists($from)) {
|
||||
|
|
@ -344,27 +260,6 @@ class File extends FileAbstract
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a file.
|
||||
*
|
||||
* If the directory doesn't exist where the file should be moved to it will be created
|
||||
* as well as potential parent directories. The directories will be created with '0644'
|
||||
* permission.
|
||||
*
|
||||
* @param string $from The path of the file to move.
|
||||
* @param string $to The path and name of the file where to move it.
|
||||
* @param bool $overwrite Should the file be overwritten if it already exists.
|
||||
*
|
||||
* @example File::move('/var/www/html/test.txt', '/var/www/html/test2.txt'); // true
|
||||
* @example File::move('/var/www/html/test.txt', '/var/www/html/test2.txt'); // false
|
||||
*
|
||||
* @return bool Returns true on successful file move and false on failure
|
||||
*
|
||||
* @throws PathException Throws this exception if the file to move doesn't exist.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
if (!file_exists($from)) {
|
||||
|
|
@ -384,52 +279,22 @@ class File extends FileAbstract
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a file.
|
||||
*
|
||||
* @param string $path Path of the file delete.
|
||||
*
|
||||
* @return bool Returns true if the file could get deleted false otherwise.
|
||||
*
|
||||
* @throws PathException Throws this exception if the file to delete doesn't exist.
|
||||
*
|
||||
* @example File::size('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
throw new PathException($path);
|
||||
return false;
|
||||
}
|
||||
|
||||
unlink($path);
|
||||
|
||||
return !file_exists($path);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory name of a file.
|
||||
*
|
||||
* @return string Returns the directory name of the file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getDirName() : string
|
||||
{
|
||||
return basename(dirname($this->path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory path of a file.
|
||||
*
|
||||
* @return string Returns the directory path of the file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getDirPath() : string
|
||||
{
|
||||
return dirname($this->path);
|
||||
|
|
@ -443,20 +308,6 @@ class File extends FileAbstract
|
|||
return self::create($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an empty file.
|
||||
*
|
||||
* If the directory doesn't exist where the file should be created it will be created
|
||||
* as well as potential parent directories. The directories will be created with '0644'
|
||||
* permission.
|
||||
*
|
||||
* @param string $path Path of the file to create.
|
||||
*
|
||||
* @return bool Returns true if the file could get created false otherwise or if it already existed.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function create(string $path) : bool
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
|
|
@ -466,7 +317,7 @@ class File extends FileAbstract
|
|||
|
||||
touch($path);
|
||||
|
||||
return file_exists($path);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
namespace phpOMS\System\File\Local;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
|
|
@ -28,7 +28,7 @@ namespace phpOMS\System\File;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class FileAbstract implements FileInterface
|
||||
abstract class FileAbstract implements ContainerInterface
|
||||
{
|
||||
/**
|
||||
* Path.
|
||||
|
|
@ -176,16 +176,6 @@ abstract class FileAbstract implements FileInterface
|
|||
return new Directory(Directory::parent($this->path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create file/directory.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
abstract public function createNode() : bool;
|
||||
|
||||
/**
|
||||
* Get created at.
|
||||
*
|
||||
305
System/File/Local/LocalStorage.php
Normal file
305
System/File/Local/LocalStorage.php
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File\Local;
|
||||
use phpOMS\System\File\ContainerInterface;
|
||||
use phpOMS\System\File\FileInterface;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\System\File\StorageAbstract;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
*
|
||||
* Performing operations on the file system
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\System\File
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class LocalStorage extends StorageAbstract
|
||||
{
|
||||
|
||||
public static function created(string $path) : \DateTime
|
||||
{
|
||||
// TODO: Implement created() method.
|
||||
}
|
||||
|
||||
public static function changed(string $path) : \DateTime
|
||||
{
|
||||
// TODO: Implement changed() method.
|
||||
}
|
||||
|
||||
public static function owner(string $path) : int
|
||||
{
|
||||
// TODO: Implement owner() method.
|
||||
}
|
||||
|
||||
public static function permission(string $path) : int
|
||||
{
|
||||
// TODO: Implement permission() method.
|
||||
}
|
||||
|
||||
public static function parent(string $path) : string
|
||||
{
|
||||
// TODO: Implement parent() method.
|
||||
}
|
||||
|
||||
public static function create(string $path) : bool
|
||||
{
|
||||
// TODO: Implement create() method.
|
||||
}
|
||||
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
// TODO: Implement delete() method.
|
||||
}
|
||||
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copy() method.
|
||||
}
|
||||
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement move() method.
|
||||
}
|
||||
|
||||
public static function size(string $path) : int
|
||||
{
|
||||
// TODO: Implement size() method.
|
||||
}
|
||||
|
||||
public static function exists(string $path) : bool
|
||||
{
|
||||
// TODO: Implement exists() method.
|
||||
}
|
||||
|
||||
public function getCount() : int
|
||||
{
|
||||
// TODO: Implement getCount() method.
|
||||
}
|
||||
|
||||
public function getSize() : int
|
||||
{
|
||||
// TODO: Implement getSize() method.
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
{
|
||||
// TODO: Implement getName() method.
|
||||
}
|
||||
|
||||
public function getPath() : string
|
||||
{
|
||||
// TODO: Implement getPath() method.
|
||||
}
|
||||
|
||||
public function getParent() : FileInterface
|
||||
{
|
||||
// TODO: Implement getParent() method.
|
||||
}
|
||||
|
||||
public function createNode() : bool
|
||||
{
|
||||
// TODO: Implement createNode() method.
|
||||
}
|
||||
|
||||
public function copyNode() : bool
|
||||
{
|
||||
// TODO: Implement copyNode() method.
|
||||
}
|
||||
|
||||
public function moveNode() : bool
|
||||
{
|
||||
// TODO: Implement moveNode() method.
|
||||
}
|
||||
|
||||
public function deleteNode() : bool
|
||||
{
|
||||
// TODO: Implement deleteNode() method.
|
||||
}
|
||||
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
// TODO: Implement getCreatedAt() method.
|
||||
}
|
||||
|
||||
public function getChangedAt() : \DateTime
|
||||
{
|
||||
// TODO: Implement getChangedAt() method.
|
||||
}
|
||||
|
||||
public function getOwner() : int
|
||||
{
|
||||
// TODO: Implement getOwner() method.
|
||||
}
|
||||
|
||||
public function getPermission() : string
|
||||
{
|
||||
// TODO: Implement getPermission() method.
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// TODO: Implement index() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current element
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @return mixed Can return any type.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
// TODO: Implement current() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Move forward to next element
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @return void Any returned value is ignored.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
// TODO: Implement next() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the key of the current element
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @return mixed scalar on success, or null on failure.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
// TODO: Implement key() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current position is valid
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @return boolean The return value will be casted to boolean and then evaluated.
|
||||
* Returns true on success or false on failure.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
// TODO: Implement valid() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the Iterator to the first element
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @return void Any returned value is ignored.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
// TODO: Implement rewind() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a offset exists
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
||||
* @param mixed $offset <p>
|
||||
* An offset to check for.
|
||||
* </p>
|
||||
* @return boolean true on success or false on failure.
|
||||
* </p>
|
||||
* <p>
|
||||
* The return value will be casted to boolean if non-boolean was returned.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
// TODO: Implement offsetExists() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to retrieve
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to retrieve.
|
||||
* </p>
|
||||
* @return mixed Can return all value types.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
// TODO: Implement offsetGet() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to set
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to assign the value to.
|
||||
* </p>
|
||||
* @param mixed $value <p>
|
||||
* The value to set.
|
||||
* </p>
|
||||
* @return void
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
// TODO: Implement offsetSet() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to unset
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to unset.
|
||||
* </p>
|
||||
* @return void
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
// TODO: Implement offsetUnset() method.
|
||||
}
|
||||
|
||||
public static function put(string $path, string $content, bool $overwrite = true) : bool
|
||||
{
|
||||
// TODO: Implement put() method.
|
||||
}
|
||||
|
||||
public static function get(string $path) : string
|
||||
{
|
||||
// TODO: Implement get() method.
|
||||
}
|
||||
|
||||
public function putContent() : bool
|
||||
{
|
||||
// TODO: Implement putContent() method.
|
||||
}
|
||||
|
||||
public function getContent() : string
|
||||
{
|
||||
// TODO: Implement getContent() method.
|
||||
}
|
||||
|
||||
protected function getType() : ContainerInterface
|
||||
{
|
||||
// TODO: Implement getType() method.
|
||||
}
|
||||
}
|
||||
57
System/File/Storage.php
Normal file
57
System/File/Storage.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
*
|
||||
* Performing operations on the file system
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\System\File
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class Storage
|
||||
{
|
||||
private static $registered = [];
|
||||
|
||||
public static function env(string $env = 'local') : string
|
||||
{
|
||||
if (isset(self::$registered[$env])) {
|
||||
$env = self::$registered[$env];
|
||||
} else {
|
||||
$env = ucfirst(strtolower($env));
|
||||
$env = __NAMESPACE__ . '\\' . $env . '\\' . $env . 'Storage';
|
||||
}
|
||||
|
||||
return $env::getInstance();
|
||||
}
|
||||
|
||||
public static function register(string $name, string $class) : bool
|
||||
{
|
||||
if (isset(self::$registered[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$registered[$name] = $class;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
49
System/File/StorageAbstract.php
Normal file
49
System/File/StorageAbstract.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
*
|
||||
* Performing operations on the file system
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\System\File
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class StorageAbstract implements DirectoryInterface, FileInterface
|
||||
{
|
||||
protected static $instance = null;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if(!isset(static::$instance)) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
abstract protected function getType() : ContainerInterface;
|
||||
}
|
||||
123
Utils/Parser/Markdown/Markdown.php
Normal file
123
Utils/Parser/Markdown/Markdown.php
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\Utils\Parser\Markdown;
|
||||
|
||||
/**
|
||||
* Array utils.
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\Utils
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Markdown
|
||||
{
|
||||
private static $blockTypes = [
|
||||
'#' => ['Header'],
|
||||
'*' => ['Rule', 'List'],
|
||||
'+' => ['List'],
|
||||
'-' => ['SetextHeader', 'Table', 'Rule', 'List'],
|
||||
'0' => ['List'],
|
||||
'1' => ['List'],
|
||||
'2' => ['List'],
|
||||
'3' => ['List'],
|
||||
'4' => ['List'],
|
||||
'5' => ['List'],
|
||||
'6' => ['List'],
|
||||
'7' => ['List'],
|
||||
'8' => ['List'],
|
||||
'9' => ['List'],
|
||||
':' => ['Table'],
|
||||
'<' => ['Comment', 'Markup'],
|
||||
'=' => ['SetextHeader'],
|
||||
'>' => ['Quote'],
|
||||
'[' => ['Reference'],
|
||||
'_' => ['Rule'],
|
||||
'`' => ['FencedCode'],
|
||||
'|' => ['Table'],
|
||||
'~' => ['FencedCode'],
|
||||
];
|
||||
|
||||
private static $inlineTypes = [
|
||||
'"' => ['SpecialCharacter'],
|
||||
'!' => ['Image'],
|
||||
'&' => ['SpecialCharacter'],
|
||||
'*' => ['Emphasis'],
|
||||
':' => ['Url'],
|
||||
'<' => ['UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'],
|
||||
'>' => ['SpecialCharacter'],
|
||||
'[' => ['Link'],
|
||||
'_' => ['Emphasis'],
|
||||
'`' => ['Code'],
|
||||
'~' => ['Strikethrough'],
|
||||
'\\' => ['EscapeSequence'],
|
||||
];
|
||||
|
||||
private static $tags = [
|
||||
'calendar' => [
|
||||
'match' => 'regex here',
|
||||
'parsed' => 'output here',
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function parse(string $raw) : string
|
||||
{
|
||||
$raw = $this->cleanup($raw);
|
||||
$lines = explode("\n", $raw);
|
||||
|
||||
return trim($this->parseLines($lines), " \n");
|
||||
}
|
||||
|
||||
private function cleanup(string $raw) : string
|
||||
{
|
||||
$raw = str_replace(["\r\n", "\r", "\t"], ["\n", "\n", ' '], $raw);
|
||||
$raw = trim($raw);
|
||||
$raw = trim($raw, "\n");
|
||||
|
||||
return $raw;
|
||||
}
|
||||
|
||||
private function parseLines(array $lines) : string
|
||||
{
|
||||
$block = array_keys(self::$blockTypes);
|
||||
$inline = array_keys(self::$inlineTypes);
|
||||
|
||||
foreach($lines as $line) {
|
||||
foreach($line as $character) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function countIndention(string $line) : int
|
||||
{
|
||||
$indent = 0;
|
||||
while (isset($line[$indent]) && $line[$indent] === ' ') {
|
||||
$indent++;
|
||||
}
|
||||
|
||||
return $indent;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user