Commit 7edf13c2 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Revert to links for changing folder rather than submit buttons

parent 7ef02a69
......@@ -35,7 +35,7 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('artefact', 'file');
define('TITLE', get_string('sitefiles', 'admin'));
$form = pieform(ArtefactTypeFileBase::files_form(null, 'mahara'));
$form = pieform(ArtefactTypeFileBase::files_form(get_config('wwwroot') . 'admin/site/files.php', null, 'mahara'));
$js = ArtefactTypeFileBase::files_js();
$smarty = smarty();
......
......@@ -127,6 +127,7 @@ $form = pieform(array(
'folder' => $folder,
'highlight' => $highlight,
'browse' => $browse,
'page' => get_config('wwwroot') . 'artefact/blog/post.php?' . ($blogpost ? ('id=' . $blogpost) : ('blog=' . $blog)) . '&browse=1',
'config' => array(
'upload' => true,
'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'),
......@@ -380,12 +381,10 @@ function editpost_submit(Pieform $form, $values) {
'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog,
);
if ($form->submitted_by_js()) {
global $SESSION;
// Redirect back to the blog page from within the iframe
$url = json_encode($result['goto']);
global $SESSION;
$SESSION->add_ok_msg($result['message']);
echo "<html><head></head><body onload='parent.location.href={$url};'></body></html>";
exit;
$form->json_reply(PIEFORM_OK, $result, false);
}
$form->reply(PIEFORM_OK, $result);
}
......
......@@ -100,6 +100,8 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$smarty->assign('initjs', $initjs);
$smarty->assign('querybase', $element['page'] . (strpos($element['page'], '?') === false ? '?' : '&'));
return $smarty->fetch('artefact:file:form/filebrowser.tpl');
}
......@@ -128,6 +130,7 @@ function pieform_element_filebrowser_build_path($form, $element, $folder) {
$smarty = smarty_core();
$smarty->assign('path', array_reverse($path));
$smarty->assign('querybase', $element['page'] . (strpos($element['page'], '?') === false ? '?' : '&'));
return array('html' => $smarty->fetch('artefact:file:form/folderpath.tpl'), 'foldername' => $foldername);
}
......@@ -150,6 +153,7 @@ function pieform_element_filebrowser_build_filelist($form, $element, $folder, $h
$smarty->assign('selectable', (int) $element['config']['select']);
$filedata = ArtefactTypeFileBase::get_my_files_data($folder, $userid, $group, $institution);
$smarty->assign('filelist', $filedata);
$smarty->assign('querybase', $element['page'] . (strpos($element['page'], '?') === false ? '?' : '&'));
return array(
'data' => $filedata,
......@@ -291,9 +295,8 @@ function pieform_element_filebrowser_doupdate(Pieform $form, $element, $folder)
$element['selectcallback']($result['highlight']);
}
}
else if (!empty($_POST['changefolder']) && is_array($_POST['changefolder'])) {
$keys = array_keys($_POST['changefolder']);
$newfolder = (int) $keys[0];
else if (is_numeric($_POST['changefolder'])) {
$newfolder = (int) $_POST['changefolder'];
$result = pieform_element_filebrowser_changefolder($form, $element, $newfolder);
$result['browse'] = 1;
$folder = $newfolder;
......
......@@ -41,7 +41,8 @@ define('TITLE', $group->name . ' - ' . get_string('groupfiles', 'artefact.file')
require_once(get_config('docroot') . 'interaction/lib.php');
$form = pieform(ArtefactTypeFileBase::files_form($group->id, null));
$pagebase = get_config('wwwroot') . 'artefact/file/groupfiles.php?group=' . $group;
$form = pieform(ArtefactTypeFileBase::files_form($pagebase, $group->id));
$js = ArtefactTypeFileBase::files_js();
$smarty = smarty();
......
......@@ -34,7 +34,7 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('myfiles', 'artefact.file'));
safe_require('artefact', 'file');
$form = pieform(ArtefactTypeFileBase::files_form(null, null));
$form = pieform(ArtefactTypeFileBase::files_form(get_config('wwwroot') . 'artefact/file/index.php'));
$js = ArtefactTypeFileBase::files_js();
$smarty = smarty(
......
......@@ -44,7 +44,8 @@ $s = institution_selector_for_page($institution,
$institution = $s['institution'];
$form = pieform(ArtefactTypeFileBase::files_form(null, $institution));
$pagebase = get_config('wwwroot') . 'artefact/file/institutionfiles.php?institution=' . $institution;
$form = pieform(ArtefactTypeFileBase::files_form($pagebase, null, $institution));
$js = ArtefactTypeFileBase::files_js();
$smarty = smarty();
......
......@@ -151,13 +151,6 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
}
this.browse_submit = function (e) {
signal(self.form, 'onsubmit');
self.form.submit();
e.stop();
return false;
}
this.upload_success = function (data) {
if (data.problem) {
var image = 'images/icon_problem.gif';
......@@ -201,6 +194,14 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
this.edit_init = function () { augment_tags_control(self.id + '_edit_tags'); }
this.browse_submit = function (e) {
signal(self.form, 'onsubmit');
self.form.submit();
e.stop();
$(self.id + '_changefolder').value = '';
return false;
}
this.browse_init = function () {
if (self.config.edit) {
forEach(getElementsByTagAndClassName('button', null, 'filelist'), function (elem) {
......@@ -236,6 +237,14 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
});
forEach(getElementsByTagAndClassName('tr', 'folder', 'filelist'), self.make_row_droppable);
}
forEach(getElementsByTagAndClassName('a', 'changefolder', self.id + '_upload_browse'), function (elem) {
connect(elem, 'onclick', function (e) {
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?')+1));
$(self.id + '_changefolder').value = params.folder;
self.browse_submit(e);
});
});
if ($(self.id + '_createfolder')) {
connect($(self.id + '_createfolder'), 'onclick', self.createfolder_submit);
}
......@@ -423,6 +432,9 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
self.browse_init();
}
else if (data.goto) {
location.href = data.goto;
}
else if (typeof(data.replaceHTML) == 'string') {
formSuccess(form, data);
self.init();
......
......@@ -505,7 +505,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
return $filedata;
}
public static function files_form($group=null, $institution=null, $folder=null, $highlight=null, $edit=null) {
public static function files_form($page='', $group=null, $institution=null, $folder=null, $highlight=null, $edit=null) {
$folder = param_integer('folder', 0);
$edit = param_variable('edit', 0);
if (is_array($edit)) {
......@@ -535,6 +535,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
'folder' => $folder,
'highlight' => $highlight,
'edit' => $edit,
'page' => $page,
'config' => array(
'upload' => true,
'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'),
......
......@@ -7,6 +7,7 @@
</script>
<input type="hidden" name="folder" id="{$prefix}_folder" value="{$folder}" />
<input type="hidden" name="changefolder" id="{$prefix}_changefolder" value="" />
<input type="hidden" name="foldername" id="{$prefix}_foldername" value="{$foldername}" />
{if $config.select && !$browse}
......@@ -77,11 +78,11 @@
{/if}
<div id="{$prefix}_foldernav" class="foldernav">
{include file="artefact:file:form/folderpath.tpl" path=$path}
{include file="artefact:file:form/folderpath.tpl" path=$path querybase=$querybase}
</div>
<div id="{$prefix}_filelist_container">
{include file="artefact:file:form/filelist.tpl" filelist=$filelist editable=$config.edit selectable=$config.select highlight=$highlight edit=$edit}
{include file="artefact:file:form/filelist.tpl" filelist=$filelist editable=$config.edit selectable=$config.select highlight=$highlight edit=$edit querybase=$querybase}
</div>
{* Edit form used when js is available *}
......
......@@ -26,8 +26,7 @@
</td>
<td class="filename">
{if $file->artefacttype == 'folder'}
<!--a href="?folder={$file->id}{$queryparams}" class="changefolder" title="{str tag=gotofolder section=artefact.file arg1=$file->title}">{$file->title|str_shorten:34}</a-->
<button type="submit" class="changefolder link" name="changefolder[{$file->id}]" title="{str tag=gotofolder section=artefact.file arg1=$file->title}" value="{$file->id}">{$file->title|str_shorten:34}</button>
<a href="{$querybase}folder={$file->id}" class="changefolder" title="{str tag=gotofolder section=artefact.file arg1=$file->title}">{$file->title|str_shorten:34}</a>
{else}
<a href="{$WWWROOT}artefact/file/download.php?file={$file->id}" title="{str tag=downloadfile section=artefact.file arg1=$file->title}">{$file->title|str_shorten:34}</a>
{/if}
......
{foreach from=$path item=f name=path}
{if !$smarty.foreach.path.first}/ {/if}
<button type="submit" class="changefolder link" name="changefolder[{$f->id}]" title="{str tag=gotofolder section=artefact.file arg1=$f->title}" value="{$f->id}">{$f->title|str_shorten:34}</button>
<!--a href="?folder={$f->id}{$queryparams}" class="changefolder">{$f->title}</a-->
{if !$smarty.foreach.path.first}/ {/if}<a href="{$querybase}folder={$f->id}" class="changefolder">{$f->title}</a>
{/foreach}
......@@ -204,22 +204,6 @@ a:hover {
font-size: 11px;
color: #FFF;
}
/* buttons that should show as links */
button.link {
color: #7f9d16;
background: transparent !important;
border: none;
display: inline;
width: auto;
overflow: visible;
margin: 0 !important;
padding: 0 !important;
font-size: 12px !important;
}
button.link:hover {
color: #84aa00;
/* text-decoration: underline !important; */
}
span.addicon {
display: block;
margin-top: -16px;
......@@ -1791,8 +1775,6 @@ tr.uploadform th {
font-size: 18px;
background: url(../images/foldernav.gif) no-repeat left 2px;
}
.foldernav button.link,
.directory-item.folder td.filename button.link,
.directory-item.folder td.filename {
font-weight: bold;
}
......@@ -1800,9 +1782,6 @@ tr.uploadform th {
font-style: italic;
color: #999;
}
.directory-item.parentfolder td.filename button.link {
font-weight: normal;
}
.filelist tr.folderhover.directory-item td {
background-color: #ffc !important;
}
......
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