Fix after bug fixes and file changes

This commit is contained in:
Dennis Eichhorn 2016-08-20 12:02:41 +02:00
parent 1c59c7bce0
commit 0d7c17aa88
7 changed files with 64 additions and 46 deletions

View File

@ -104,12 +104,11 @@ class FileLogger implements LoggerInterface
} }
if (is_dir($lpath) || strpos($lpath, '.') === false) { if (is_dir($lpath) || strpos($lpath, '.') === false) {
Directory::create($lpath, '0644'); File::create($path = $lpath . '/' . date('Y-m-d') . '.log');
File::createFile($path = $lpath . '/' . date('Y-m-d') . '.log');
$path = realpath($path); $path = realpath($path);
} else { } else {
File::createFile($lpath); File::create($lpath);
$path = realpath($lpath); $path = realpath($lpath);
} }

View File

@ -235,7 +235,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
*/ */
public function createNode() : bool public function createNode() : bool
{ {
return self::createPath($this->path, $this->permission, true); return self::create($this->path, $this->permission, true);
} }
/** /**
@ -433,7 +433,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
// TODO: Implement owner() method. // TODO: Implement owner() method.
} }
public static function permission(string $path) : string public static function permission(string $path) : int
{ {
// TODO: Implement permission() method. // TODO: Implement permission() method.
} }
@ -463,13 +463,13 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
// TODO: Implement get() method. // TODO: Implement get() method.
} }
public static function size(string $path) : string public static function size(string $path) : int
{ {
// TODO: Implement size() method. // TODO: Implement size() method.
} }
public static function exists(string $path) : bool public static function exists(string $path) : bool
{ {
// TODO: Implement exists() method. return file_exists($path);
} }
} }

View File

@ -49,6 +49,16 @@ class File extends FileAbstract
} }
} }
public function getDirName() : string
{
return basename(dirname($this->path));
}
public function getDirPath() : string
{
return dirname($this->path);
}
/** /**
* Index file. * Index file.
* *
@ -113,6 +123,18 @@ class File extends FileAbstract
return false; return false;
} }
public function getFileName() : string
{
return explode('.', $this->name)[0];
}
public function getExtension() : string
{
$extension = explode('.', $this->name);
return $extension[1] ?? '';
}
public static function get(string $path) : string public static function get(string $path) : string
{ {
if(!file_exists($path)) { if(!file_exists($path)) {
@ -127,7 +149,7 @@ class File extends FileAbstract
return file_exists($path); return file_exists($path);
} }
public static function create(string $path) : string public static function create(string $path) : bool
{ {
if(!file_exists($path)) { if(!file_exists($path)) {
if(!Directory::exists(dirname($path))) { if(!Directory::exists(dirname($path))) {
@ -186,7 +208,7 @@ class File extends FileAbstract
throw new PathException($path); throw new PathException($path);
} }
return fileperms($path); return fileowner($path);
} }
public static function permission(string $path) : int public static function permission(string $path) : int
@ -195,7 +217,7 @@ class File extends FileAbstract
throw new PathException($path); throw new PathException($path);
} }
return fileowner($path); return fileperms($path);
} }
public static function dirname(string $path) : string public static function dirname(string $path) : string

View File

@ -68,7 +68,7 @@ interface FileInterface
public static function owner(string $path) : int; public static function owner(string $path) : int;
public static function permission(string $path) : string; public static function permission(string $path) : int;
public static function parent(string $path) : string; public static function parent(string $path) : string;
@ -84,7 +84,7 @@ interface FileInterface
public static function get(string $path) : string; public static function get(string $path) : string;
public static function size(string $path) : string; public static function size(string $path) : int;
public static function exists(string $path) : bool; public static function exists(string $path) : bool;
} }

View File

@ -95,13 +95,21 @@ class Http implements UriInterface
*/ */
private $path = ''; private $path = '';
/**
* Uri query.
*
* @var array
* @since 1.0.0
*/
private $query = [];
/** /**
* Uri query. * Uri query.
* *
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private $query = null; private $queryString = '';
/** /**
* Uri fragment. * Uri fragment.
@ -138,18 +146,18 @@ class Http implements UriInterface
public function set(string $uri) public function set(string $uri)
{ {
$this->uri = $uri; $this->uri = $uri;
$url = parse_url($this->uri);
$url = parse_url($this->uri); $this->scheme = $url['scheme'] ?? '';
$this->host = $url['host'] ?? null;
$this->scheme = $url['scheme'] ?? ''; $this->port = $url['port'] ?? null;
$this->host = $url['host'] ?? null; $this->user = $url['user'] ?? null;
$this->port = $url['port'] ?? null; $this->pass = $url['pass'] ?? null;
$this->user = $url['user'] ?? null; $this->path = $url['path'] ?? null;
$this->pass = $url['pass'] ?? null; $this->path = rtrim($this->path, '.php');
$this->path = $url['path'] ?? null; $this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language
$this->path = rtrim($this->path, '.php'); $this->query = $url['query'] ?? null;
$this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language $this->queryString = $this->query;
$this->query = $url['query'] ?? null;
if (isset($this->query)) { if (isset($this->query)) {
parse_str($this->query, $this->query); parse_str($this->query, $this->query);
@ -192,7 +200,7 @@ class Http implements UriInterface
*/ */
public function getRootPath() : string public function getRootPath() : string
{ {
return $this->rootPath; return $this->rootPath ?? '';
} }
/** /**
@ -209,7 +217,7 @@ class Http implements UriInterface
*/ */
public function getScheme() : string public function getScheme() : string
{ {
return $this->scheme; return $this->scheme ?? '';
} }
/** /**
@ -217,7 +225,7 @@ class Http implements UriInterface
*/ */
public function getHost() : string public function getHost() : string
{ {
return $this->host; return $this->host ?? '';
} }
/** /**
@ -225,7 +233,7 @@ class Http implements UriInterface
*/ */
public function getPort() : int public function getPort() : int
{ {
return $this->port; return $this->port ?? 80;
} }
/** /**
@ -238,7 +246,7 @@ class Http implements UriInterface
*/ */
public function getPass() : string public function getPass() : string
{ {
return $this->pass; return $this->pass ?? '';
} }
/** /**
@ -246,7 +254,7 @@ class Http implements UriInterface
*/ */
public function getPath() : string public function getPath() : string
{ {
return $this->path; return $this->path ?? '';
} }
/** /**
@ -254,7 +262,7 @@ class Http implements UriInterface
*/ */
public function getQuery(string $key = null) public function getQuery(string $key = null)
{ {
return isset($key) ? $this->query[$key] ?? null : $this->query; return isset($key) ? $this->query[$key] ?? null : $this->queryString ?? '';
} }
/** /**
@ -262,7 +270,7 @@ class Http implements UriInterface
*/ */
public function getFragment() : string public function getFragment() : string
{ {
return $this->fragment; return $this->fragment ?? '';
} }
/** /**
@ -270,7 +278,7 @@ class Http implements UriInterface
*/ */
public function getBase() : string public function getBase() : string
{ {
return $this->base; return $this->base ?? '';
} }
/** /**
@ -299,7 +307,7 @@ class Http implements UriInterface
*/ */
public function getUser() : string public function getUser() : string
{ {
return $this->user; return $this->user ?? '';
} }
/** /**

View File

@ -19,8 +19,6 @@ use phpOMS\ApplicationAbstract;
use phpOMS\Localization\Localization; use phpOMS\Localization\Localization;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\System\File\PathException;
use phpOMS\Utils\StringUtils;
/** /**
* List view. * List view.
@ -169,7 +167,7 @@ class View extends ViewAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private function getText(string $translation, string $module = null, string $theme = null) protected function getText(string $translation, string $module = null, string $theme = null)
{ {
if (!isset($module)) { if (!isset($module)) {
$match = '/Modules/'; $match = '/Modules/';

View File

@ -15,12 +15,7 @@
*/ */
namespace phpOMS\Views; namespace phpOMS\Views;
use phpOMS\ApplicationAbstract;
use phpOMS\Localization\Localization;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\System\File\PathException; use phpOMS\System\File\PathException;
use phpOMS\Utils\StringUtils;
/** /**
* List view. * List view.
@ -55,10 +50,6 @@ abstract class ViewAbstract implements \Serializable
/** /**
* Constructor. * Constructor.
* *
* @param ApplicationAbstract $app Application
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Request
*
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */