Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
9b26cb0b
Commit
9b26cb0b
authored
13 years ago
by
Arthur Schiwon
Browse files
Options
Downloads
Patches
Plain Diff
implement "new folder" function
parent
60b68256
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
files/ajax/newfolder.php
+29
-0
29 additions, 0 deletions
files/ajax/newfolder.php
files/css/files.css
+2
-2
2 additions, 2 deletions
files/css/files.css
files/js/files.js
+55
-7
55 additions, 7 deletions
files/js/files.js
files/templates/index.php
+3
-4
3 additions, 4 deletions
files/templates/index.php
with
89 additions
and
13 deletions
files/ajax/newfolder.php
0 → 100644
+
29
−
0
View file @
9b26cb0b
<?php
// Init owncloud
require_once
(
'../../lib/base.php'
);
// We send json data
header
(
"Content-Type: application/jsonrequest"
);
// Check if we are a user
if
(
!
OC_USER
::
isLoggedIn
()){
echo
json_encode
(
array
(
"status"
=>
"error"
,
"data"
=>
array
(
"message"
=>
"Authentication error"
)));
exit
();
}
// Get the params
$dir
=
isset
(
$_GET
[
'dir'
]
)
?
$_GET
[
'dir'
]
:
''
;
$foldername
=
isset
(
$_GET
[
'foldername'
]
)
?
$_GET
[
'foldername'
]
:
''
;
if
(
$foldername
==
''
)
{
echo
json_encode
(
array
(
"status"
=>
"error"
,
"data"
=>
array
(
"message"
=>
"Empty Foldername"
)));
exit
();
}
error_log
(
'try to create '
.
$foldername
.
' in '
.
$dir
);
if
(
OC_FILES
::
newFile
(
$dir
,
$foldername
,
'dir'
))
{
echo
json_encode
(
array
(
"status"
=>
"success"
,
"data"
=>
array
()));
exit
();
}
echo
json_encode
(
array
(
"status"
=>
"error"
,
"data"
=>
array
(
"message"
=>
"Error when creating the folder"
)));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
files/css/files.css
+
2
−
2
View file @
9b26cb0b
...
...
@@ -23,11 +23,11 @@
display
:
none
;
}
#file_
upload_target
{
#file_
newfolder_form
{
display
:
none
;
}
#file_
action_panel
{
#file_
upload_target
{
display
:
none
;
}
...
...
This diff is collapsed.
Click to expand it.
files/js/files.js
+
55
−
7
View file @
9b26cb0b
$
(
document
).
ready
(
function
()
{
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
,
false
);
// Sets browser table behaviour :
$
(
'
.browser tr
'
).
hover
(
function
()
{
...
...
@@ -37,16 +39,43 @@ $(document).ready(function() {
$
(
'
.browser input:checkbox
'
).
attr
(
'
checked
'
,
false
);
});
// Shows and hides file upload form
$
(
'
#file_upload_button
'
).
toggle
(
function
()
{
$
(
'
#file_upload_form
'
).
css
({
"
display
"
:
"
block
"
});
},
function
()
{
$
(
'
#file_upload_form
'
).
css
({
"
display
"
:
"
none
"
});
});
$
(
'
#file_upload_start
'
).
click
(
function
()
{
$
(
'
#file_upload_target
'
).
load
(
uploadFinished
);
});
$
(
'
#file_new_dir_submit
'
).
click
(
function
()
{
$
.
ajax
({
url
:
'
ajax/newfolder.php
'
,
data
:
"
dir=
"
+
$
(
'
#dir
'
).
val
()
+
"
&foldername=
"
+
$
(
'
#file_new_dir_name
'
).
val
(),
complete
:
boolOpFinished
});
});
$
(
'
.upload
'
).
click
(
function
(){
if
(
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
)
!=
'
upload
'
)
{
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
,
'
upload
'
);
$
(
'
#fileSelector
'
).
replaceWith
(
'
<input type="file" name="file" id="fileSelector">
'
);
$
(
'
#file_action_panel form
'
).
css
({
"
display
"
:
"
none
"
});
$
(
'
#file_upload_form
'
).
css
({
"
display
"
:
"
block
"
});
}
else
{
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
,
'
false
'
);
$
(
'
#file_upload_form
'
).
css
({
"
display
"
:
"
none
"
})
}
return
false
;
});
$
(
'
.new-dir
'
).
click
(
function
(){
if
(
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
)
!=
'
new-dir
'
)
{
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
,
'
new-dir
'
);
$
(
'
#file_new_dir_name
'
).
val
(
''
);
$
(
'
#file_action_panel form
'
).
css
({
"
display
"
:
"
none
"
});
$
(
'
#file_newfolder_form
'
).
css
({
"
display
"
:
"
block
"
})
}
else
{
$
(
'
#file_newfolder_form
'
).
css
({
"
display
"
:
"
none
"
})
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
,
false
);
}
return
false
;
});
});
function
uploadFinished
()
{
...
...
@@ -64,6 +93,24 @@ function uploadFinished() {
}
}
function
resetFileActionPanel
()
{
$
(
'
#file_action_panel form
'
).
css
({
"
display
"
:
"
none
"
});
$
(
'
#file_action_panel
'
).
attr
(
'
activeAction
'
,
false
);
}
function
boolOpFinished
(
data
)
{
result
=
eval
(
"
(
"
+
data
.
responseText
+
"
);
"
);
if
(
result
.
status
==
'
success
'
){
$
.
ajax
({
url
:
'
ajax/list.php
'
,
data
:
"
dir=
"
+
$
(
'
#dir
'
).
val
(),
complete
:
refreshContents
});
}
else
{
alert
(
result
.
data
.
message
);
}
}
function
refreshContents
(
data
)
{
result
=
eval
(
"
(
"
+
data
.
responseText
+
"
);
"
);
if
(
typeof
(
result
.
data
.
breadcrumb
)
!=
'
undefined
'
){
...
...
@@ -71,6 +118,7 @@ function refreshContents(data) {
}
updateFileList
(
result
.
data
.
files
);
$
(
'
#file_upload_button
'
).
click
();
resetFileActionPanel
();
}
function
updateBreadcrumb
(
breadcrumbHtml
)
{
...
...
This diff is collapsed.
Click to expand it.
files/templates/index.php
+
3
−
4
View file @
9b26cb0b
...
...
@@ -5,16 +5,15 @@ href="" title="" class="new-dir">New folder</a><a href="" title=""
class=
"download"
>
Download
</a><a
href=
""
title=
""
class=
"share"
>
Share
</a><a
href=
""
title=
""
class=
"delete"
>
Delete
</a>
</p>
<div
id=
"file_
upload_form
"
>
<form
action=
"ajax/upload.php"
<div
id=
"file_
action_panel
"
>
<form
id=
"file_upload_form"
action=
"ajax/upload.php"
method=
"post"
enctype=
"multipart/form-data"
target=
"file_upload_target"
><input
type=
"hidden"
name=
"MAX_FILE_SIZE"
value=
"
<?php
echo
$_
[
"uploadMaxFilesize"
]
?>
"
id=
"max_upload"
><input
type=
"hidden"
name=
"dir"
value=
"
<?php
echo
$_
[
"dir"
]
?>
"
id=
"dir"
><input
type=
"file"
name=
"file"
id=
"fileSelector"
><input
type=
"submit"
id=
"file_upload_start"
value=
"Upload"
/><iframe
id=
"file_upload_target"
name=
"file_upload_target"
src=
""
></iframe></form>
</div>
<div
id=
"file_action_panel"
>
<form
id=
"file_newfolder_form"
><input
type=
"text"
name=
"file_new_dir_name"
id=
"file_new_dir_name"
/>
<input
type=
"button"
id=
"file_new_dir_submit"
name=
"file_new_dir_submit"
value=
"OK"
/></form>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment