Commit b080cdf9 authored by Jamie Carl's avatar Jamie Carl 🤙🏼

Merge branch 'master' into 2.4-stable

parents f4bbdd8c 887d065c
......@@ -121,9 +121,18 @@
background-color: #ddd;
}
.fb-container .fb-left,
.fb-container .fb-main {
position: absolute;
top: 0px;
}
.fb-container .fb-topbar ~ .fb-left,
.fb-container .fb-topbar ~ .fb-main {
top: 60px;
}
.fb-container .fb-main {
position: absolute;
left: 250px;
right: 300px;
bottom: 0;
......@@ -134,9 +143,8 @@
right: 0;
}
.fb-container .fb-tree {
.fb-container .fb-left {
position: absolute;
top: 60px;
left: 0;
width: 250px;
bottom: 0;
......@@ -144,24 +152,26 @@
color: #444;
overflow-y: auto;
overflow-x: hidden;
padding-top: 25px;
}
.fb-container .fb-tree .fb-tree-control {
padding: 25px 0 25px 35px;
.fb-container .fb-left .fb-tree-control {
text-align: center;
}
.fb-container .fb-tree button.fb-btn-new {
.fb-container .fb-left button.fb-btn-new {
width: 60%;
background: #554d7c;
color: #fff;
margin-bottom: 25px;
}
.fb-container .fb-tree .fb-tree-control button.fb-btn-new:hover {
.fb-container .fb-left .fb-tree-control button.fb-btn-new:hover {
box-shadow: inset -4px -4px 8px rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
.fb-container .fb-tree .fb-tree-control button.fb-btn-new:active {
.fb-container .fb-left .fb-tree-control button.fb-btn-new:active {
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}
......
This diff is collapsed.
......@@ -263,11 +263,11 @@ class Error extends \Hazaar\Controller\Action {
if(is_array($response)) {
$response = new Response\Json($response);
$response = new Response\Json($response, $this->code);
} else {
$response = new Response\Html();
$response = new Response\Html($this->code);
/*
* Execute the action helpers. These are responsible for actually rendering any views.
......
......@@ -442,7 +442,7 @@ class Media extends \Hazaar\Controller\Action {
ksort($args);
$response = call_user_func_array(array($connector, $cmd), $args);
$response = $method->invokeArgs($connector, $args);
if(strtolower($this->request->getHeader('X-Request-Type')) == 'stream')
return $this->stream($response);
......
......@@ -110,15 +110,16 @@ class BrowserConnector {
}
public function info(\Hazaar\File\Manager $source, \Hazaar\File $file) {
public function info(\Hazaar\File\Manager $source, $file) {
if($file->fullpath() == '/')
$parent = $this->target($source);
if(!($file instanceof \Hazaar\File || $file instanceof \Hazaar\File\Dir))
throw new \Exception('$file must be either Hazaar\File or Hazaar\File\Dir when calling info()');
else
$parent = $this->target($source, $file->dirname());
$is_dir = $file instanceof \Hazaar\File\Dir || $file->is_dir();
$parent = ($file->fullpath() == '/') ? $this->target($source) : $this->target($source, $file->dirname() . '/');
$fileId = $this->target($source, $source->fixPath($file->dirname(), $file->basename()));
$fileId = $this->target($source, $source->fixPath($file->dirname(), $file->basename()) . ($is_dir ? '/' : ''));
$linkURL = rtrim($this->url, '/') . '/' . $source->name . rtrim($file->dirname(), '/') . '/' . $file->basename();
......@@ -139,7 +140,7 @@ class BrowserConnector {
'write' => $file->is_writable()
);
if($file->is_dir()) {
if($is_dir) {
$info['dirs'] = 0;
......@@ -174,23 +175,33 @@ class BrowserConnector {
if(! $source = $this->source($target))
return FALSE;
$dir = $source->dir($this->path($target));
$path = trim($this->path($target));
while(($file = $dir->read()) !== FALSE) {
$dir = $source->dir($path);
if(! $file->is_dir())
continue;
if(substr($path, -1) === '/'){
$tree[] = $this->info($source, $file);
while(($file = $dir->read()) !== FALSE) {
if($depth > 0 || $depth === NULL) {
if(! $file->is_dir())
continue;
$sub = $this->tree($this->target($source, $file->fullpath()), (($depth !== NULL) ? $depth - 1 : NULL));
$tree[] = $this->info($source, $file);
$tree = array_merge($tree, $sub);
if($depth > 0 || $depth === NULL) {
$sub = $this->tree($this->target($source, $file->fullpath()), (($depth !== NULL) ? $depth - 1 : NULL));
$tree = array_merge($tree, $sub);
}
}
}else{
$tree = array($this->info($source, $dir));
}
} else {
......@@ -242,7 +253,7 @@ class BrowserConnector {
$files = array();
$path = $source->fixPath($this->path($target));
$path = $source->fixPath($this->path($target)) . '/';
$dir = $source->dir($path);
......@@ -611,7 +622,7 @@ class BrowserConnector {
$path = $this->path($target);
$list = $source->find('*' . $query . '*', $path);
$list = $source->find('*' . $query . '*', $path, true);
if(!is_array($list))
throw new \Exception('Search failed!');
......
......@@ -50,12 +50,48 @@ class Dir {
}
public function fullpath($suffix = null){
return $this->path($suffix);
}
public function realpath($suffix = NULL) {
return $this->backend->realpath($this->fixPath($this->path, $suffix));
}
public function dirname(){
return str_replace('\\', '/', dirname($this->fixPath($this->path)));
}
public function basename(){
return basename($this->fixPath($this->path));
}
public function mtime(){
return $this->backend->filemtime($this->fixPath($this->path));
}
public function size(){
return $this->backend->filesize($this->fixPath($this->path));
}
public function type(){
return $this->backend->filetype($this->fixPath($this->path));
}
public function exists() {
return $this->backend->exists($this->path);
......@@ -222,10 +258,7 @@ class Dir {
*/
public function find($pattern, $show_hidden = FALSE, $case_sensitive = TRUE, $start = NULL) {
if(! $start)
$start = $this->path;
$start = rtrim($start, $this->backend->separator) . $this->backend->separator;
$start = rtrim($this->path . ($start ? '/' . ltrim($start, DIRECTORY_SEPARATOR . '/.') : '' ), $this->backend->separator) . $this->backend->separator;
$list = array();
......@@ -237,7 +270,7 @@ class Dir {
if(($show_hidden === FALSE && substr($file, 0, 1) == '.') || $file == '.' || $file == '..')
continue;
if(is_dir($start . $file)) {
if($this->backend->is_dir($start . $file)) {
if($subdir = $this->find($pattern, $show_hidden, $case_sensitive, $start . $file))
$list = array_merge($list, $subdir);
......@@ -249,7 +282,7 @@ class Dir {
if(preg_match($pattern . ($case_sensitive ? NULL : 'i'), $file) == 0)
continue;
} elseif(! fnmatch($pattern, $file))
} elseif(! fnmatch($pattern, $file, $case_sensitive ? 0 : FNM_CASEFOLD))
continue;
$list[] = new \Hazaar\File($start . $file, $this->backend, $this->manager, $this->path);
......
......@@ -230,10 +230,10 @@ class Manager {
}
public function find($search = NULL, $path = '/') {
public function find($search = NULL, $path = '/', $case_insensitive = false) {
if(method_exists($this->backend, 'find'))
return $this->backend->find($search, $path);
return $this->backend->find($search, $path, $case_insensitive);
$dir = $this->dir($path);
......@@ -256,10 +256,10 @@ class Manager {
if((ctype_alnum($first) || $first == '\\') == false
&& $first == substr($search, -1, 1)) {
if(! preg_match($search, $file->basename()))
if(! preg_match($search . ($case_insensitive ? 'i' : ''), $file->basename()))
continue;
} elseif(! fnmatch($search, $file->basename())) {
} elseif(! fnmatch($search, $file->basename(), ($case_insensitive ? FNM_CASEFOLD : 0))) {
continue;
......
......@@ -1532,4 +1532,30 @@ function array_diff_assoc_recursive() {
return $difference;
}
/**
* Recursively convert an object into an array.
*
* This is basically a recursive version of PHP's get_object_vars().
*
* @param object $object The object to convert.
* @return array|boolean Returns the converted object as an array or false on failure.
*/
function object_to_array($object){
if(!is_object($object))
return false;
$array = get_object_vars($object);
foreach($array as &$value) {
if(is_object($value))
$value = object_to_array($value);
}
return $array;
}
\ No newline at end of file
......@@ -16,7 +16,9 @@ class Client {
private $cookies = array();
private $context = NULL;
private $local_cert = NULL;
private $cert_passphrase = NULL;
private $auto_redirect = TRUE;
......@@ -43,25 +45,9 @@ class Client {
function __construct($local_cert = NULL, $passphrase = NULL, $debug = FALSE) {
$this->context = stream_context_create();
if($local_cert) {
if(! file_exists($local_cert)) {
throw new Exception\CertificateNotFound();
}
stream_context_set_option($this->context, 'ssl', 'local_cert', $local_cert);
$this->local_cert = $local_cert;
if($passphrase) {
stream_context_set_option($this->context, 'ssl', 'passphrase', $passphrase);
}
}
$this->cert_passphrase = $passphrase;
$this->debug = $debug;
......@@ -182,6 +168,9 @@ class Client {
}
if($this->local_cert)
$request->setLocalCertificate($this->local_cert, $this->cert_passphrase);
if($this->auth)
$request->authorisation($this->auth);
......@@ -190,7 +179,7 @@ class Client {
$this->applyCookies($request);
$sck_fd = @stream_socket_client($request->getHost(), $errno, $errstr, $this->connection_timeout, STREAM_CLIENT_CONNECT, $this->context);
$sck_fd = @stream_socket_client($request->getHost(), $errno, $errstr, $this->connection_timeout, STREAM_CLIENT_CONNECT, $request->context);
if($sck_fd) {
......
......@@ -12,15 +12,17 @@ class Request extends \Hazaar\Map {
'Connection' => 'close'
);
private $raw_uri;
private $raw_uri;
private $uri;
private $uri;
private $fsock_host;
private $fsock_host;
private $body = NULL;
private $body = null;
function __construct($uri = NULL, $method = 'GET', $content_type = NULL) {
public $context = null;
function __construct($uri = null, $method = 'GET', $content_type = null, $custom_context = null) {
if($method)
$this->method = $method;
......@@ -43,6 +45,8 @@ class Request extends \Hazaar\Map {
$this->uri($uri);
$this->context = is_resource($custom_context) ? $custom_context : stream_context_create();
}
/**
......@@ -53,7 +57,7 @@ class Request extends \Hazaar\Map {
*/
public function uri($uri = null){
if($uri === NULL)
if($uri === null)
return $this->uri;
$this->raw_uri = $uri;
......@@ -93,7 +97,7 @@ class Request extends \Hazaar\Map {
}
public function addMultipart($data, $content_type = NULL) {
public function addMultipart($data, $content_type = null) {
if(! $content_type) {
......@@ -423,4 +427,89 @@ class Request extends \Hazaar\Map {
}
/**
* Set a local PEM encoded certificate to use for SSL communication
*
* @param mixed $local_cert
* @param mixed $passphrase
* @throws Exception\CertificateNotFound
* @return boolean
*/
public function setLocalCertificate($local_cert, $passphrase = null, $local_pk = null){
if(!file_exists((string)$local_cert))
throw new Exception\CertificateNotFound();
$result = stream_context_set_option($this->context, 'ssl', 'local_cert', $local_cert);
if($local_pk){
if(!file_exists((string)$local_pk))
throw new \Exception('Local private key specified but the file does not exist!');
stream_context_set_option($this->context, 'ssl', 'local_pk', $local_pk);
}
if($passphrase)
stream_context_set_option($this->context, 'ssl', 'passphrase', $passphrase);
return $result;
}
/**
* Wrapper function to the internal PHP function stream_context_set_option() function.
*
* See http://php.net/manual/en/context.ssl.php documentation for all the available wrappers and options.
*
* @param mixed $options Must be an associative array in the format $arr['wrapper']['option'] = $value;
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setContextOption($options){
return stream_context_set_option($this->context, $options);
}
/**
* When using SSL communications, this allows the use of self-signed certificates.
*
* @param boolean $value
*
* @return boolean
*/
public function allowSelfSigned($value = true){
return stream_context_set_option($this->context, 'ssl', 'allow_self_signed', $value);
}
/**
* When using SSL communications, this sets whether peer certificate verification is used.
*
* @param boolean $value
*
* @return boolean
*/
public function verifyPeer($value = true){
return stream_context_set_option($this->context, 'ssl', 'verify_peer', $value);
}
/**
* When using SSL communications, this sets whether peer name verification is used.
*
* @param boolean $value
*
* @return boolean
*/
public function verifyPeerName($value = true){
return stream_context_set_option($this->context, 'ssl', 'verify_peer_name', $value);
}
}
......@@ -84,6 +84,8 @@ class ChildArray extends DataTypeConverter implements \ArrayAccess, \Iterator, \
}
settype($criteriaValue, gettype($value));
if($value !== $criteriaValue)
return false;
......
......@@ -106,24 +106,32 @@ class DataBinderValue implements \JsonSerializable {
/**
* Resolve an array and look for saved value/label arrays and convert them.
*
* @param array $array The array to resolve
* @param mixed $object The object/array to resolve
* @param boolean $recursive Recurse into normal arrays. Defaults to TRUE.
* @return array
*/
static function resolve($array, $recursive = true){
static function resolve($object, $recursive = true){
foreach($array as &$value){
$array = array();
if(!is_array($value))
continue;
if(is_array($object) || $object instanceof \stdClass){
if(array_key_exists('__hz_value', $value))
$value = (DataBinderValue::create($value))->value;
elseif($recursive === true)
$value = DataBinderValue::resolve($value);
foreach($object as $key => $value){
if((is_array($value) && array_key_exists('__hz_value', $value)) || ($value instanceof \stdClass && property_exists($value, '__hz_value')))
$value = (DataBinderValue::create($value))->value;
elseif($recursive === true)
$value = DataBinderValue::resolve($value);
$array[$key] = $value;
}
}
if(count($array) === 0)
return null;
return $array;
}
......
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