Commit dc27140a authored by Mario's avatar Mario
Browse files

streamline variable naming

parent 3e54cc27
Pipeline #369544 passed with stage
in 2 minutes and 38 seconds
......@@ -97,15 +97,15 @@ class Browser extends DAV\Browser\Plugin {
$files = $this->server->getPropertiesForPath($path, [], 1);
$parent = $this->server->tree->getNodeForPath($path);
$parentpath = [];
$parent_path = [];
// only show parent if not leaving /cloud/; TODO how to improve this?
if ($path && $path !== 'cloud') {
list($parentUri) = \Sabre\Uri\split($path);
$fullPath = \Sabre\HTTP\encodePath($this->server->getBaseUri() . $parentUri);
list($parent_uri) = \Sabre\Uri\split($path);
$full_path = \Sabre\HTTP\encodePath($this->server->getBaseUri() . $parent_uri);
$parentpath['icon'] = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="' . t('parent') . '"></a>' : '';
$parentpath['path'] = $fullPath;
$parent_path['icon'] = $this->enableAssets ? '<a href="' . $full_path . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="' . t('parent') . '"></a>' : '';
$parent_path['path'] = $full_path;
}
$folder_list = attach_folder_select_list($this->auth->owner_id);
......@@ -125,12 +125,9 @@ class Browser extends DAV\Browser\Plugin {
continue;
$node = $this->server->tree->getNodeForPath($href);
$data = $node->data;
$attachHash = $data['hash'];
$parentHash = $node->folder_hash;
$attach_hash = $data['hash'];
$parent_hash = $node->folder_hash;
list(, $filename) = \Sabre\Uri\split($href);
......@@ -205,9 +202,9 @@ class Browser extends DAV\Browser\Plugin {
$is_creator = (($data['creator'] === get_observer_hash()) ? true : false);
if(strpos($type,'image/') === 0 && $attachHash) {
if(strpos($type,'image/') === 0 && $attach_hash) {
$p = q("select resource_id, imgscale from photo where resource_id = '%s' and imgscale in ( %d, %d ) order by imgscale asc limit 1",
dbesc($attachHash),
dbesc($attach_hash),
intval(PHOTO_RES_320),
intval(PHOTO_RES_PROFILE_80)
);
......@@ -219,7 +216,7 @@ class Browser extends DAV\Browser\Plugin {
}
}
$g = [ 'resource_id' => $attachHash, 'thumbnail' => $photo_icon, 'security' => $preview_style ];
$g = [ 'resource_id' => $attach_hash, 'thumbnail' => $photo_icon, 'security' => $preview_style ];
call_hooks('file_thumbnail', $g);
$photo_icon = $g['thumbnail'];
......@@ -248,22 +245,21 @@ class Browser extends DAV\Browser\Plugin {
}
// put the array for this file together
$ft['attachId'] = $id;
$ft['attach_id'] = $id;
$ft['fileStorageUrl'] = substr($href, 0, strpos($href, "/cloud/")) . "/filestorage/" . $this->auth->owner_nick;
$ft['icon'] = $icon;
$ft['photo_icon'] = $photo_icon;
$ft['attachIcon'] = (($size) ? $attachIcon : '');
$ft['is_owner'] = $is_owner;
$ft['is_creator'] = $is_creator;
$ft['relPath'] = '/cloud/' . $nick .'/' . $data['display_path'];
$ft['fullPath'] = z_root() . '/cloud/' . $nick .'/' . $data['display_path'];
$ft['displayName'] = $name;
$ft['rel_path'] = '/cloud/' . $nick .'/' . $data['display_path'];
$ft['full_path'] = z_root() . '/cloud/' . $nick .'/' . $data['display_path'];
$ft['name'] = $name;
$ft['type'] = $type;
$ft['size'] = $size;
$ft['collection'] = (($type === 'Collection') ? true : false);
$ft['sizeFormatted'] = userReadableSize($size);
$ft['lastmodified'] = (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(), $lastmodified) : '');
$ft['iconFromType'] = getIconFromType($type);
$ft['size_formatted'] = userReadableSize($size);
$ft['last_modified'] = (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(), $lastmodified) : '');
$ft['icon_from_type'] = getIconFromType($type);
$ft['allow_cid'] = acl2json($data['allow_cid']);
$ft['allow_gid'] = acl2json($data['allow_gid']);
......@@ -286,7 +282,7 @@ class Browser extends DAV\Browser\Plugin {
$folders = $folder_list;
if($data['is_dir']) {
// can not copy a folder into itself
unset($folders[$parentHash]);
unset($folders[$parent_hash]);
}
$ft['newfolder'] = ['newfolder_' . $id, t('Select a target location'), $data['folder'], '', $folders];
......@@ -308,8 +304,8 @@ class Browser extends DAV\Browser\Plugin {
$tiles = ((array_key_exists('cloud_tiles',$_SESSION)) ? intval($_SESSION['cloud_tiles']) : $deftiles);
$_SESSION['cloud_tiles'] = $tiles;
if(get_config('system', 'cloud_disable_siteroot') && $parentpath['path'] === '/cloud') {
$parentpath = [];
if(get_config('system', 'cloud_disable_siteroot') && $parent_path['path'] === '/cloud') {
$parent_path = [];
}
$header = (($cat) ? t('File category') . ": " . $this->escapeHTML($cat) : t('Files') . ": " . $this->escapeHTML($path) . "/");
......@@ -324,7 +320,7 @@ class Browser extends DAV\Browser\Plugin {
'$is_owner' => $is_owner,
'$is_admin' => is_site_admin(),
'$admin_delete' => t('Admin Delete'),
'$parentpath' => $parentpath,
'$parentpath' => $parent_path,
'$cpath' => bin2hex(App::$query_string),
'$tiles' => intval($_SESSION['cloud_tiles']),
'$entries' => $f,
......
......@@ -21,18 +21,18 @@
{{foreach $entries as $item}}
<div class="cloud-container">
<div class="cloud-icon tiles"><a href="{{$item.relPath}}">
<div class="cloud-icon tiles"><a href="{{$item.rel_path}}">
{{if $item.photo_icon}}
<img src="{{$item.photo_icon}}" title="{{$item.type}}" >
{{else}}
<div class="cloud-icon-container">
<i class="fa fa-fw {{$item.iconFromType}}" title="{{$item.type}}"></i>
<i class="fa fa-fw {{$item.icon_from_type}}" title="{{$item.type}}"></i>
</div>
{{/if}}
</div>
<div class="cloud-title">
<a href="{{$item.relPath}}">
{{$item.displayName}}
<a href="{{$item.rel_path}}">
{{$item.name}}
</a>
</div>
{{if $item.is_owner}}
......@@ -61,89 +61,87 @@
{{/if}}
<tr id="new-upload-progress-bar-1"></tr> {{* this is needed to append the upload files in the right order *}}
{{foreach $entries as $item}}
<tr id="cloud-index-{{$item.attachId}}" class="cloud-index">
<td><i class="fa {{$item.iconFromType}}" title="{{$item.type}}"></i></td>
<td><a href="{{$item.relPath}}" class="p-2">{{$item.displayName}}</a></td>
<tr id="cloud-index-{{$item.attach_id}}" class="cloud-index">
<td><i class="fa {{$item.icon_from_type}}" title="{{$item.type}}"></i></td>
<td><a href="{{$item.rel_path}}" class="p-2">{{$item.name}}</a></td>
<td>{{$item.terms}}</td>
<td class="cloud-index-tool p-2">{{if $item.lockstate == 'lock'}}<i class="fa fa-fw fa-{{$item.lockstate}}"></i>{{/if}}</td>
{{if $item.is_owner}}
<td class="cloud-index-tool">
{{if $item.is_owner && $item.attach_id}}
<div class="dropdown">
<button class="btn btn-link btn-sm" id="dropdown-button-{{$item.attachId}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-link btn-sm" id="dropdown-button-{{$item.attach_id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-v"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button-{{$item.attachId}}">
<a id="cloud-tool-perms-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-perms-btn" href="#" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-{{$item.lockstate}}"></i> Adjust permissions</a>
<a id="cloud-tool-rename-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-rename-btn" href="#" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-pencil"></i> Rename</a>
<a id="cloud-tool-move-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-move-btn" href="#" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-copy"></i> Move or copy</a>
<a id="cloud-tool-categories-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-categories-btn" href="#" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-asterisk"></i> Categories</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button-{{$item.attach_id}}">
<a id="cloud-tool-perms-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-perms-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-{{$item.lockstate}}"></i> Adjust permissions</a>
<a id="cloud-tool-rename-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-rename-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-pencil"></i> Rename</a>
<a id="cloud-tool-move-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-move-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-copy"></i> Move or copy</a>
<a id="cloud-tool-categories-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-categories-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-asterisk"></i> Categories</a>
{{if !$item.collection}}
<a id="cloud-tool-share-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-share-btn" href="/rpost?attachment=[attachment]{{$item.resource}},{{$item.revision}}[/attachment]&acl[allow_cid]={{$item.raw_allow_cid}}&acl[allow_gid]={{$item.raw_allow_gid}}&acl[deny_cid]={{$item.raw_deny_cid}}&acl[deny_gid]={{$item.raw_deny_gid}}" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-share-square-o"></i> Post</a>
<a id="cloud-tool-download-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-download-btn" href="/attach/{{$item.resource}}" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
<a id="cloud-tool-share-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-share-btn" href="/rpost?attachment=[attachment]{{$item.resource}},{{$item.revision}}[/attachment]&acl[allow_cid]={{$item.raw_allow_cid}}&acl[allow_gid]={{$item.raw_allow_gid}}&acl[deny_cid]={{$item.raw_deny_cid}}&acl[deny_gid]={{$item.raw_deny_gid}}" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-share-square-o"></i> Post</a>
<a id="cloud-tool-download-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-download-btn" href="/attach/{{$item.resource}}" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
{{/if}}
<a id="cloud-tool-delete-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-delete-btn" href="#" data-id="{{$item.attachId}}" onclick="dropItem('{{$item.fileStorageUrl}}/{{$item.attachId}}/delete/json', '#cloud-index-{{$item.attachId}},#cloud-tools-{{$item.attachId}}'); return false;"><i class="fa fa-fw fa-trash-o"></i> {{$delete}}</a>
<a id="cloud-tool-delete-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-delete-btn" href="#" data-id="{{$item.attach_id}}" onclick="dropItem('{{$item.fileStorageUrl}}/{{$item.attach_id}}/delete/json', '#cloud-index-{{$item.attach_id}},#cloud-tools-{{$item.attach_id}}'); return false;"><i class="fa fa-fw fa-trash-o"></i> {{$delete}}</a>
</div>
</div>
</td>
{{else}}
<td class="cloud-index-tool">
{{if $item.is_creator || $is_admin || !$item.collection}}
{{else}}
{{if ($item.is_creator || $is_admin || !$item.collection) && $item.attach_id}}
<div class="dropdown">
<button class="btn btn-link btn-sm" id="dropdown-button-{{$item.attachId}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-link btn-sm" id="dropdown-button-{{$item.attach_id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-v"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button-{{$item.attachId}}">
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button-{{$item.attach_id}}">
{{if !$item.collection}}
<a id="cloud-tool-download-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-download-btn" href="/attach/{{$item.resource}}" data-id="{{$item.attachId}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
<a id="cloud-tool-download-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-download-btn" href="/attach/{{$item.resource}}" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
{{/if}}
{{if $item.is_creator || $is_admin}}
<a id="cloud-tool-delete-btn-{{$item.attachId}}" class="dropdown-item cloud-tool-delete-btn" href="#" data-id="{{$item.attachId}}" onclick="dropItem('{{$item.fileStorageUrl}}/{{$item.attachId}}/delete/json', '#cloud-index-{{$item.attachId}},#cloud-tools-{{$item.attachId}}'); return false;"><i class="fa fa-fw fa-trash-o"></i> {{if $item.is_creator}}{{$delete}}{{else}}{{$admin_delete}}{{/if}}</a>
<a id="cloud-tool-delete-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-delete-btn" href="#" data-id="{{$item.attach_id}}" onclick="dropItem('{{$item.fileStorageUrl}}/{{$item.attach_id}}/delete/json', '#cloud-index-{{$item.attach_id}},#cloud-tools-{{$item.attach_id}}'); return false;"><i class="fa fa-fw fa-trash-o"></i> {{if $item.is_creator}}{{$delete}}{{else}}{{$admin_delete}}{{/if}}</a>
{{/if}}
</div>
</div>
{{/if}}
</td>
{{/if}}
<td class="d-none d-md-table-cell p-2">{{$item.sizeFormatted}}</td>
<td class="d-none d-md-table-cell p-2">{{$item.lastmodified}}</td>
<td class="d-none d-md-table-cell p-2">{{$item.size_formatted}}</td>
<td class="d-none d-md-table-cell p-2">{{$item.last_modified}}</td>
</tr>
<tr id="cloud-tools-{{$item.attachId}}" class="cloud-tools">
<td id="attach-edit-panel-{{$item.attachId}}" colspan="7">
<form id="attach_edit_form_{{$item.attachId}}" action="attach_edit/{{$nick}}/{{$item.attachId}}" method="post" class="acl-form" data-form_id="attach_edit_form_{{$item.attachId}}" data-allow_cid='{{$item.allow_cid}}' data-allow_gid='{{$item.allow_gid}}' data-deny_cid='{{$item.deny_cid}}' data-deny_gid='{{$item.deny_gid}}'>
<input type="hidden" name="attach_id" value="{{$item.attachId}}" />
<tr id="cloud-tools-{{$item.attach_id}}" class="cloud-tools">
<td id="attach-edit-panel-{{$item.attach_id}}" colspan="7">
<form id="attach_edit_form_{{$item.attach_id}}" action="attach_edit/{{$nick}}/{{$item.attach_id}}" method="post" class="acl-form" data-form_id="attach_edit_form_{{$item.attach_id}}" data-allow_cid='{{$item.allow_cid}}' data-allow_gid='{{$item.allow_gid}}' data-deny_cid='{{$item.deny_cid}}' data-deny_gid='{{$item.deny_gid}}'>
<input type="hidden" name="attach_id" value="{{$item.attach_id}}" />
<input type="hidden" name="resource" value="{{$item.resource}}" />
<input type="hidden" name="filename" value="{{$item.displayName}}" />
<input type="hidden" name="filename" value="{{$item.name}}" />
<input type="hidden" name="folder" value="{{$item.folder}}" />
<div id="cloud-tool-rename-{{$item.attachId}}" class="cloud-tool">
<div id="cloud-tool-rename-{{$item.attach_id}}" class="cloud-tool">
{{include file="field_input.tpl" field=$item.newfilename}}
</div>
<div id="cloud-tool-move-{{$item.attachId}}" class="cloud-tool">
<div id="cloud-tool-move-{{$item.attach_id}}" class="cloud-tool">
{{include file="field_select.tpl" field=$item.newfolder}}
{{include file="field_checkbox.tpl" field=$item.copy}}
</div>
<div id="cloud-tool-categories-{{$item.attachId}}" class="cloud-tool">
<div id="cloud-tool-categories-{{$item.attach_id}}" class="cloud-tool">
{{include file="field_input.tpl" field=$item.categories}}
</div>
<div id="cloud-tool-submit-{{$item.attachId}}" class="cloud-tool">
<div id="cloud-tool-submit-{{$item.attach_id}}" class="cloud-tool">
{{if !$item.collection}}{{include file="field_checkbox.tpl" field=$item.notify}}{{/if}}
{{if $item.collection}}{{include file="field_checkbox.tpl" field=$item.recurse}}{{/if}}
<div id="attach-submit-{{$item.attachId}}" class="form-group">
<button id="cloud-tool-cancel-btn-{{$item.attachId}}" class="btn btn-outline-secondary btn-sm cloud-tool-cancel-btn" type="button" data-id="{{$item.attachId}}">
<div id="attach-submit-{{$item.attach_id}}" class="form-group">
<button id="cloud-tool-cancel-btn-{{$item.attach_id}}" class="btn btn-outline-secondary btn-sm cloud-tool-cancel-btn" type="button" data-id="{{$item.attach_id}}">
Cancel
</button>
<div id="attach-edit-perms-{{$item.attachId}}" class="btn-group float-right">
<button id="dbtn-acl-{{$item.attachId}}" class="btn btn-outline-secondary btn-sm" data-toggle="modal" data-target="#aclModal" title="{{$permset}}" type="button">
<i id="jot-perms-icon-{{$item.attachId}}" class="fa fa-{{$item.lockstate}} jot-icons jot-perms-icon"></i>
<div id="attach-edit-perms-{{$item.attach_id}}" class="btn-group float-right">
<button id="dbtn-acl-{{$item.attach_id}}" class="btn btn-outline-secondary btn-sm" data-toggle="modal" data-target="#aclModal" title="{{$permset}}" type="button">
<i id="jot-perms-icon-{{$item.attach_id}}" class="fa fa-{{$item.lockstate}} jot-icons jot-perms-icon"></i>
</button>
<button id="dbtn-submit-{{$item.attachId}}" class="btn btn-primary btn-sm" type="submit" name="submit">
<button id="dbtn-submit-{{$item.attach_id}}" class="btn btn-primary btn-sm" type="submit" name="submit">
{{$edit}}
</button>
</div>
</div>
</div>
<!--div id="cloud-tool-share-{{$item.attachId}}" class="">
<div id="attach-edit-tools-share-{{$item.attachId}}" class="btn-group form-group">
<button id="link-btn-{{$item.attachId}}" class="btn btn-outline-secondary btn-sm" type="button" onclick="openClose('link-code-{{$item.attachId}}');" title="{{$link_btn_title}}">
<!--div id="cloud-tool-share-{{$item.attach_id}}" class="">
<div id="attach-edit-tools-share-{{$item.attach_id}}" class="btn-group form-group">
<button id="link-btn-{{$item.attach_id}}" class="btn btn-outline-secondary btn-sm" type="button" onclick="openClose('link-code-{{$item.attach_id}}');" title="{{$link_btn_title}}">
<i class="fa fa-link jot-icons"></i>
</button>
</div>
......@@ -153,9 +151,9 @@
<i class="fa fa-share-square-o jot-icons"></i>
</a>
{{/if}}
<div id="link-code-{{$item.attachId}}" class="form-group link-code">
<label for="linkpasteinput-{{$item.attachId}}">{{$cpldesc}}</label>
<input type="text" class="form-control" id="linkpasteinput-{{$item.attachId}}" name="linkpasteinput-{{$item.attachId}}" value="{{$item.fullPath}}" onclick="this.select();"/>
<div id="link-code-{{$item.attach_id}}" class="form-group link-code">
<label for="linkpasteinput-{{$item.attach_id}}">{{$cpldesc}}</label>
<input type="text" class="form-control" id="linkpasteinput-{{$item.attach_id}}" name="linkpasteinput-{{$item.attach_id}}" value="{{$item.full_path}}" onclick="this.select();"/>
</div-->
</form>
</td>
......
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