diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index 43c66af5d..5639d871d 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -15,7 +15,7 @@ */ namespace phpOMS\DataStorage\Cache; -use phpOMS\System\File\Directory; +use phpOMS\System\File\Local\Directory; /** * MemCache class. diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index dd60ceac2..89239de23 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -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. diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 2b706cbbb..ce79d414d 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -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; diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 0d790b188..426ee52f6 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -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; diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 16e5ec8a2..640452127 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -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. diff --git a/System/File/ContainerInterface.php b/System/File/ContainerInterface.php new file mode 100644 index 000000000..1ba1d1ca9 --- /dev/null +++ b/System/File/ContainerInterface.php @@ -0,0 +1,82 @@ + + * @author Dennis Eichhorn + * @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 + * @author Dennis Eichhorn + * @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(); +} diff --git a/System/File/NullFile.php b/System/File/DirectoryInterface.php similarity index 89% rename from System/File/NullFile.php rename to System/File/DirectoryInterface.php index ed5c4f40c..ba4c9e7e7 100644 --- a/System/File/NullFile.php +++ b/System/File/DirectoryInterface.php @@ -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 { - -} \ No newline at end of file +} diff --git a/System/File/FileInterface.php b/System/File/FileInterface.php index 76af1146c..fc47deb25 100644 --- a/System/File/FileInterface.php +++ b/System/File/FileInterface.php @@ -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(); } diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php new file mode 100644 index 000000000..e69de29bb diff --git a/System/File/Directory.php b/System/File/Local/Directory.php similarity index 96% rename from System/File/Directory.php rename to System/File/Local/Directory.php index 2e2b04ed4..8d0c2d6eb 100644 --- a/System/File/Directory.php +++ b/System/File/Local/Directory.php @@ -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 */ - 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. diff --git a/System/File/File.php b/System/File/Local/File.php similarity index 59% rename from System/File/File.php rename to System/File/Local/File.php index 3d7d3df76..e52f628bd 100644 --- a/System/File/File.php +++ b/System/File/Local/File.php @@ -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 + * @since 1.0.0 + * @author Dennis Eichhorn */ 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 + * @since 1.0.0 + * @author Dennis Eichhorn */ 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 + * @since 1.0.0 + * @author Dennis Eichhorn */ 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 + * @since 1.0.0 + * @author Dennis Eichhorn */ 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 + * @since 1.0.0 + * @author Dennis Eichhorn */ 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 + * @since 1.0.0 + * @author Dennis Eichhorn */ 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 - */ 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 - */ 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 - * - * @example File::size('/var/www/html/test.txt'); - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ 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 - */ 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 - */ - 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 - */ 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 - */ 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 - */ 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 - */ 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 - */ 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 - */ 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; diff --git a/System/File/FileAbstract.php b/System/File/Local/FileAbstract.php similarity index 94% rename from System/File/FileAbstract.php rename to System/File/Local/FileAbstract.php index ba0bef6be..84ac380a9 100644 --- a/System/File/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -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 - */ - abstract public function createNode() : bool; - /** * Get created at. * diff --git a/System/File/Local/LocalStorage.php b/System/File/Local/LocalStorage.php new file mode 100644 index 000000000..cbc9a10cb --- /dev/null +++ b/System/File/Local/LocalStorage.php @@ -0,0 +1,305 @@ + + * @author Dennis Eichhorn + * @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 + * @author Dennis Eichhorn + * @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

+ * An offset to check for. + *

+ * @return boolean true on success or false on failure. + *

+ *

+ * 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

+ * The offset to retrieve. + *

+ * @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

+ * The offset to assign the value to. + *

+ * @param mixed $value

+ * The value to set. + *

+ * @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

+ * The offset to unset. + *

+ * @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. + } +} \ No newline at end of file diff --git a/System/File/Storage.php b/System/File/Storage.php new file mode 100644 index 000000000..f289bbdd9 --- /dev/null +++ b/System/File/Storage.php @@ -0,0 +1,57 @@ + + * @author Dennis Eichhorn + * @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 + * @author Dennis Eichhorn + * @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; + } +} diff --git a/System/File/StorageAbstract.php b/System/File/StorageAbstract.php new file mode 100644 index 000000000..f3ce96770 --- /dev/null +++ b/System/File/StorageAbstract.php @@ -0,0 +1,49 @@ + + * @author Dennis Eichhorn + * @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 + * @author Dennis Eichhorn + * @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; +} diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php new file mode 100644 index 000000000..2b79709c2 --- /dev/null +++ b/Utils/Parser/Markdown/Markdown.php @@ -0,0 +1,123 @@ + + * @author Dennis Eichhorn + * @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 + * @author Dennis Eichhorn + * @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; + } +} \ No newline at end of file