added file addition and file editing feature in the file show view

enhanced the file home view to show a file entry without actual upload files.
updated the wiki show view not to use the colum-count css element when the count is 1
This commit is contained in:
hyung-hwan 2015-09-12 05:45:24 +00:00
parent 798ff45888
commit 65b0e818cc
7 changed files with 749 additions and 67 deletions

View File

@ -404,7 +404,7 @@ class File extends Controller
if (strpos($_FILES[$fid]['name'], ':') !== FALSE || if (strpos($_FILES[$fid]['name'], ':') !== FALSE ||
strpos($_FILES[$fid]['name'], '/') !== FALSE) strpos($_FILES[$fid]['name'], '/') !== FALSE)
{ {
/* for wiki */ // prevents these letters for wiki creole
$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; $status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}";
break; break;
} }
@ -435,6 +435,172 @@ class File extends Controller
print $status; print $status;
} }
function xhr_add_file ($projectid = '', $name = '')
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('FileModel', 'files');
$this->load->library ('upload');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$name = $this->converter->HexToAscii ($name);
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$status = "error - failed to get the project {$projectid}";
}
else if ($project === NULL)
{
$status = "error - no such project {$projectid}";
}
else if (!$login['sysadmin?'] &&
$this->projects->projectHasMember($projectid, $login['id']) === FALSE)
{
$status = "error - not a member {$login['id']}";
}
else
{
$post_add_file_count = $this->input->post('file_add_file_count');
if ($post_add_file_count === FALSE || $post_add_file_count <= 0) $post_add_file_count = 0;
$status = '';
$add_files = array ();
for ($i = 0; $i < $post_add_file_count; $i++)
{
$fid = "file_add_file_{$i}";
if (array_key_exists($fid, $_FILES) && $_FILES[$fid]['name'] != '')
{
$d = $this->input->post("file_add_file_desc_{$i}");
if ($d === FALSE || ($d = trim($d)) == '')
{
$status = "error - no short description for {$_FILES[$fid]['name']}";
break;
}
if (strpos($_FILES[$fid]['name'], ':') !== FALSE ||
strpos($_FILES[$fid]['name'], '/') !== FALSE)
{
// prevents these letters for wiki creole
$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}";
break;
}
array_push ($add_files, array ('fid' => $fid, 'name' => $_FILES[$fid]['name'], 'desc' => $d));
}
}
if ($status == '')
{
if (count($add_files) <= 0)
{
$status = 'error - no files uploaded';
}
else if ($this->files->addFiles ($login['id'], $projectid, $name, $add_files, $this->upload) === FALSE)
{
$status = 'error - ' . $this->files->getErrorMessage();
}
else
{
$status = 'ok';
}
}
}
}
print $status;
}
function xhr_edit_file ($projectid = '', $name = '')
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('FileModel', 'files');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$name = $this->converter->HexToAscii ($name);
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$status = "error - failed to get the project {$projectid}";
}
else if ($project === NULL)
{
$status = "error - no such project {$projectid}";
}
else if (!$login['sysadmin?'] &&
$this->projects->projectHasMember($projectid, $login['id']) === FALSE)
{
$status = "error - not a member {$login['id']}";
}
else
{
$post_edit_file_count = $this->input->post('file_edit_file_count');
if ($post_edit_file_count === FALSE || $post_edit_file_count <= 0) $post_edit_file_count = 0;
$status = '';
$edit_files = array ();
for ($i = 0; $i < $post_edit_file_count; $i++)
{
$n = $this->input->post("file_edit_file_name_{$i}");
$k = $this->input->post("file_edit_file_kill_{$i}");
$d = $this->input->post("file_edit_file_desc_{$i}");
if ($n != '')
{
if ($k == 'yes')
{
array_push ($edit_files, array ('name' => $n, 'kill' => $k));
}
else if ($d !== FALSE)
{
if (($d = trim($d)) == '')
{
$status = "error - no short description for {$n}";
break;
}
array_push ($edit_files, array ('name' => $n, 'desc' => $d));
}
}
}
if ($status == '')
{
if (count($edit_files) <= 0)
{
//$status = 'error - no input avaialble';
$status = 'ok';
}
else if ($this->files->editFiles ($login['id'], $projectid, $name, $edit_files) === FALSE)
{
$status = 'error - ' . $this->files->getErrorMessage();
}
else
{
$status = 'ok';
}
}
}
}
print $status;
}
function xhr_delete ($projectid = '', $name = '') function xhr_delete ($projectid = '', $name = '')
{ {

View File

@ -139,7 +139,6 @@ class FileModel extends Model
{ {
$this->db->trans_start (); $this->db->trans_start ();
/*
$this->db->where ('projectid', $projectid); $this->db->where ('projectid', $projectid);
$this->db->where ('name', $name); $this->db->where ('name', $name);
$this->db->set ('name', $file->name); $this->db->set ('name', $file->name);
@ -149,7 +148,9 @@ class FileModel extends Model
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->update ('file'); $this->db->update ('file');
// file_list gets updated for the schema itself (reference/trigger) // file_list gets updated for the schema itself (reference/trigger)
*/ /*
// this way of updating is bad in that it won't update info
// if there is no file items in file_list for the target file.
$this->db->where ('f.projectid', $projectid); $this->db->where ('f.projectid', $projectid);
$this->db->where ('f.name', $name); $this->db->where ('f.name', $name);
$this->db->where ('f.projectid = fl.projectid'); $this->db->where ('f.projectid = fl.projectid');
@ -161,6 +162,7 @@ class FileModel extends Model
$this->db->set ('f.updatedby', $userid); $this->db->set ('f.updatedby', $userid);
$this->db->set ('fl.name', $file->name); $this->db->set ('fl.name', $file->name);
$this->db->update ('file as f, file_list as fl'); $this->db->update ('file as f, file_list as fl');
*/
$this->db->set ('createdon', date('Y-m-d H:i:s')); $this->db->set ('createdon', date('Y-m-d H:i:s'));
$this->db->set ('type', 'file'); $this->db->set ('type', 'file');
@ -366,6 +368,178 @@ class FileModel extends Model
restore_error_handler (); restore_error_handler ();
return $x; return $x;
} }
private function _add_files ($userid, $projectid, $name, $import_files, $uploader)
{
$this->db->trans_begin (); // manual transaction. not using trans_start().
$config['allowed_types'] = '*';
$config['upload_path'] = CODEPOT_FILE_DIR;
$config['max_size'] = CODEPOT_MAX_UPLOAD_SIZE;
$config['encrypt_name'] = TRUE;
$config['overwrite'] = FALSE;
$config['remove_spaces'] = FALSE;
$uploader->initialize ($config);
$ok_files = array();
$file_count = count($import_files);
for ($i = 0; $i < $file_count; $i++)
{
$f = $import_files[$i];
if (!$uploader->do_upload($f['fid']))
{
$this->errmsg = "Failed to upload {$f['name']}";
$this->db->trans_rollback ();
$this->delete_all_files ($ok_files);
return FALSE;
}
$ud = $uploader->data();
array_push ($ok_files, $ud['full_path']);
$md5sum = @md5_file ($ud['full_path']);
if ($md5sum === FALSE)
{
$this->db->trans_rollback ();
$this->delete_all_files ($ok_files);
return FALSE;
}
$this->db->set ('projectid', $projectid);
$this->db->set ('name', $name);
$this->db->set ('filename', $f['name']);
$this->db->set ('encname', $ud['file_name']);
$this->db->set ('md5sum', $md5sum);
$this->db->set ('description', $f['desc']);
$this->db->insert ('file_list');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
$this->delete_all_files ($ok_files);
return FALSE;
}
}
$this->db->set ('createdon', date('Y-m-d H:i:s'));
$this->db->set ('type', 'file');
$this->db->set ('action', 'update');
$this->db->set ('projectid', $projectid);
$this->db->set ('userid', $userid);
$this->db->set ('message', $name);
$this->db->insert ('log');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
$this->delete_all_files ($ok_files);
return FALSE;
}
$this->db->trans_commit ();
return TRUE;
}
function addFiles ($userid, $projectid, $name, $import_files, $uploader)
{
set_error_handler (array ($this, 'capture_error'));
$errmsg = '';
$x = $this->_add_files ($userid, $projectid, $name, $import_files, $uploader);
restore_error_handler ();
return $x;
}
private function _edit_files ($userid, $projectid, $name, $edit_files)
{
$this->db->trans_begin (); // manual transaction. not using trans_start().
$kill_files = array();
$file_count = count($edit_files);
for ($i = 0; $i < $file_count; $i++)
{
$f = $edit_files[$i];
if (array_key_exists('kill', $f))
{
$this->db->where ('projectid', $projectid);
$this->db->where ('name', $name);
$this->db->where ('filename', $f['name']);
$this->db->select ('encname');
$query = $this->db->get('file_list');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
$result = $query->result ();
if (empty($result))
{
$this->errmsg = "no such file - {$f['name']}";
$this->db->trans_rollback ();
return FALSE;
}
array_push ($kill_files, CODEPOT_FILE_DIR . '/' . $result[0]->encname);
$this->db->where ('projectid', $projectid);
$this->db->where ('name', $name);
$this->db->where ('filename', $f['name']);
$query = $this->db->delete('file_list');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
}
else if (array_key_exists('desc', $f))
{
$this->db->where ('projectid', $projectid);
$this->db->where ('name', $name);
$this->db->where ('filename', $f['name']);
$this->db->set ('description', $f['desc']);
$this->db->update ('file_list');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
}
}
$this->db->set ('createdon', date('Y-m-d H:i:s'));
$this->db->set ('type', 'file');
$this->db->set ('action', 'update');
$this->db->set ('projectid', $projectid);
$this->db->set ('userid', $userid);
$this->db->set ('message', $name);
$this->db->insert ('log');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
$this->delete_all_files ($kill_files);
$this->db->trans_commit ();
return TRUE;
}
function editFiles ($userid, $projectid, $name, $edit_files)
{
set_error_handler (array ($this, 'capture_error'));
$errmsg = '';
$x = $this->_edit_files ($userid, $projectid, $name, $edit_files);
restore_error_handler ();
return $x;
}
} }
?> ?>

View File

@ -53,7 +53,6 @@ function render_wiki(input_text)
prettyPrint (); prettyPrint ();
} }
var new_item_no = 0;
var import_in_progress = false; var import_in_progress = false;
var populated_file_obj = []; var populated_file_obj = [];
var populated_file_max = 0; var populated_file_max = 0;
@ -108,8 +107,6 @@ $(function () {
<?php if (isset($login['id']) && $login['id'] != ''): ?> <?php if (isset($login['id']) && $login['id'] != ''): ?>
new_item_no = 0;
$('#file_home_mainarea_new_files').change (function () { $('#file_home_mainarea_new_files').change (function () {
populate_selected_files (); populate_selected_files ();
}); });
@ -344,15 +341,12 @@ else
$file_list_count = count($file->file_list); $file_list_count = count($file->file_list);
for ($i = 0; $i < $file_list_count; $i++) if ($file_list_count <= 0)
{ {
print "<tr class='{$rowclass}'>"; print "<tr class='{$rowclass}'>";
$f = $file->file_list[$i];
$xname = $this->converter->AsciiToHex ($f->filename);
print '<td>'; print '<td>';
if ($i == 0 && $file->tag != $oldtag) if ($file->tag != $oldtag)
{ {
print htmlspecialchars($file->tag); print htmlspecialchars($file->tag);
$oldtag = $file->tag; $oldtag = $file->tag;
@ -360,23 +354,51 @@ else
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($i == 0) print anchor ("file/show/{$project->id}/{$hexname}", htmlspecialchars($file->name)); print anchor ("file/show/{$project->id}/{$hexname}", htmlspecialchars($file->name));
print '</td>'; print '</td>';
print '<td>'; print '<td></td>';
print anchor ("file/get/{$project->id}/{$xname}", $f->filename); print '<td></td>';
print '</td>'; print '<td></td>';
print '<td>';
print htmlspecialchars($f->description);
print '</td>';
print '<td><tt>';
print $f->md5sum;
print '</tt></td>';
print '</tr>'; print '</tr>';
} }
else
{
for ($i = 0; $i < $file_list_count; $i++)
{
print "<tr class='{$rowclass}'>";
$f = $file->file_list[$i];
$xname = $this->converter->AsciiToHex ($f->filename);
print '<td>';
if ($i == 0 && $file->tag != $oldtag)
{
print htmlspecialchars($file->tag);
$oldtag = $file->tag;
}
print '</td>';
print '<td>';
if ($i == 0) print anchor ("file/show/{$project->id}/{$hexname}", htmlspecialchars($file->name));
print '</td>';
print '<td>';
print anchor ("file/get/{$project->id}/{$xname}", htmlspecialchars($f->filename));
print '</td>';
print '<td>';
print htmlspecialchars($f->description);
print '</td>';
print '<td><tt>';
print $f->md5sum;
print '</tt></td>';
print '</tr>';
}
}
} }
print '</table>'; print '</table>';
} }
@ -406,9 +428,7 @@ else
</div> </div>
<div id='file_home_mainarea_new_description_preview' class='form_input_preview'> <div id='file_home_mainarea_new_description_preview' class='form_input_preview'>
</div> </div>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>

View File

@ -1,4 +1,6 @@
<html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@ -23,6 +25,7 @@
<?php <?php
$hexname = $this->converter->AsciiToHex ($file->name); $hexname = $this->converter->AsciiToHex ($file->name);
$file_count = count ($file->file_list);
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -54,7 +57,100 @@ function render_wiki()
prettyPrint (); prettyPrint ();
} }
var populated_file_obj_for_adding = [];
var populated_file_max_for_adding = 0;
function populate_selected_files_for_adding ()
{
var file_desc = {};
for (var n = 0; n < populated_file_max_for_adding; n++)
{
var f = populated_file_obj_for_adding[n];
if (f != null)
{
var d = $('#file_show_mainarea_add_file_desc_' + n);
if (d != null) file_desc[f.name] = d.val();
}
}
$('#file_show_mainarea_add_file_table').empty();
populated_file_obj_for_adding = [];
var f = $('#file_show_mainarea_add_files').get(0);
var f_no = 0;
for (var n = 0; n < f.files.length; n++)
{
if (f.files[n] != null)
{
var desc = file_desc[f.files[n].name];
if (desc == null) desc = '';
$('#file_show_mainarea_add_file_table').append (
codepot_sprintf (
'<tr id="file_show_mainarea_add_file_row_%d"><td><a href="#" id="file_show_mainarea_add_file_cancel_%d" onClick="cancel_out_add_file(%d); return false;"><i class="fa fa-trash"></i></a></td><td>%s</td><td><input type="text" id="file_show_mainarea_add_file_desc_%d" size="40" value="%s" /></td></tr>',
f_no, f_no, f_no, codepot_htmlspecialchars(f.files[n].name), f_no, codepot_addslashes(desc)
)
);
populated_file_obj_for_adding[f_no] = f.files[n];
f_no++;
}
}
populated_file_max_for_adding = f_no;
}
function cancel_out_add_file (no)
{
$('#file_show_mainarea_add_file_row_' + no).remove ();
populated_file_obj_for_adding[no] = null;
}
function kill_edit_file (no)
{
var n = $('#file_show_mainarea_edit_file_name_' + no);
var d = $('#file_show_mainarea_edit_file_desc_' + no);
if (n && d)
{
if (d.prop('disabled'))
{
n.css ('text-decoration', '');
d.prop ('disabled', false);
}
else
{
n.css ('text-decoration', 'line-through');
d.prop ('disabled', true);
}
}
}
var delete_in_progress = false; var delete_in_progress = false;
var add_file_in_progress = false;
var edit_file_in_progress = false;
var original_file_name = [<?php
for ($i = 0; $i < $file_count; $i++)
{
$f = $file->file_list[$i];
printf ("%s\t'%s'", (($i == 0)? '': ",\n"), addslashes($f->filename));
}
print "\n";
?>
];
var original_file_desc = [
<?php
for ($i = 0; $i < $file_count; $i++)
{
$f = $file->file_list[$i];
printf ("%s\t'%s'", (($i == 0)? '': ",\n"), addslashes($f->description));
}
print "\n";
?>
];
$(function () { $(function () {
if ($("#file_show_mainarea_result_info").is(":visible")) if ($("#file_show_mainarea_result_info").is(":visible"))
@ -79,6 +175,11 @@ $(function () {
} }
}); });
$('#file_show_mainarea_files').accordion({
collapsible: true
});
<?php if (isset($login['id']) && $login['id'] != ''): ?> <?php if (isset($login['id']) && $login['id'] != ''): ?>
$('#file_show_mainarea_delete_form_div').dialog ( $('#file_show_mainarea_delete_form_div').dialog (
@ -155,13 +256,205 @@ $(function () {
} }
); );
$('#file_show_mainarea_add_files').change (function () {
populate_selected_files_for_adding ();
});
$('#file_show_mainarea_add_file_form_div').dialog (
{
title: '<?php print $this->lang->line('Add');?>',
resizable: true,
autoOpen: false,
width: 'auto',
height: 'auto',
modal: true,
buttons: {
'<?php print $this->lang->line('OK')?>': function () {
if (add_file_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
add_file_in_progress = true;
var form_data = new FormData();
var f_no = 0;
for (var i = 0; i <= populated_file_max_for_adding; i++)
{
var f = populated_file_obj_for_adding[i];
if (f != null)
{
form_data.append ('file_add_file_' + f_no, f);
var d = $('#file_show_mainarea_add_file_desc_' + i);
if (d != null) form_data.append('file_add_file_desc_' + f_no, d.val());
f_no++;
}
}
form_data.append ('file_add_file_count', f_no);
$('#file_show_mainarea_add_file_form_div').dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_add_file/{$project->id}/{$hexname}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
add_file_in_progress = false;
$('#file_show_mainarea_add_file_form_div').dialog('enable');
$('#file_show_mainarea_add_file_form_div').dialog('close');
if (data == 'ok')
{
// refresh the page to the head revision
$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/file/show/{$project->id}/{$hexname}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
add_file_in_progress = false;
$('#file_show_mainarea_add_file_form_div').dialog('enable');
$('#file_show_mainarea_add_file_form_div').dialog('close');
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
}
});
}
else
{
show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>");
}
},
'<?php print $this->lang->line('Cancel')?>': function () {
if (add_file_in_progress) return;
$('#file_show_mainarea_add_file_form_div').dialog('close');
}
},
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !add_file_in_progress;
}
}
);
$('#file_show_mainarea_edit_file_form_div').dialog (
{
title: '<?php print $this->lang->line('Edit');?>',
resizable: true,
autoOpen: false,
width: 'auto',
height: 'auto',
modal: true,
buttons: {
'<?php print $this->lang->line('OK')?>': function () {
if (edit_file_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
edit_file_in_progress = true;
var form_data = new FormData();
var f_no = 0;
for (var i = 0; i <= <?php print $file_count; ?>; i++)
{
var n = $('#file_show_mainarea_edit_file_name_' + i);
var d = $('#file_show_mainarea_edit_file_desc_' + i);
if (n && d)
{
if (d.prop('disabled'))
{
form_data.append ('file_edit_file_name_' + f_no, original_file_name[i]);
form_data.append('file_edit_file_kill_' + f_no, 'yes');
f_no++;
}
else if (d.val() != original_file_desc[i])
{
form_data.append ('file_edit_file_name_' + f_no, original_file_name[i]);
form_data.append('file_edit_file_desc_' + f_no, d.val());
f_no++;
}
}
}
form_data.append ('file_edit_file_count', f_no);
$('#file_show_mainarea_edit_file_form_div').dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_edit_file/{$project->id}/{$hexname}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
edit_file_in_progress = false;
$('#file_show_mainarea_edit_file_form_div').dialog('enable');
$('#file_show_mainarea_edit_file_form_div').dialog('close');
if (data == 'ok')
{
// refresh the page to the head revision
$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/file/show/{$project->id}/{$hexname}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
edit_file_in_progress = false;
$('#file_show_mainarea_edit_file_form_div').dialog('enable');
$('#file_show_mainarea_edit_file_form_div').dialog('close');
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
}
});
}
else
{
show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>");
}
},
'<?php print $this->lang->line('Cancel')?>': function () {
if (edit_file_in_progress) return;
$('#file_show_mainarea_edit_file_form_div').dialog('close');
}
},
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !edit_file_in_progress;
}
}
);
$('#file_show_mainarea_delete_button').button().click (function() { $('#file_show_mainarea_delete_button').button().click (function() {
$('#file_show_mainarea_delete_form_div').dialog('open'); $('#file_show_mainarea_delete_form_div').dialog('open');
return false; return false;
}); });
$('#file_show_mainarea_add_file_button').button (); $('#file_show_mainarea_add_file_button').button().click (function() {
$('#file_show_mainarea_delete_file_button').button (); $('#file_show_mainarea_add_file_form_div').dialog('open');
return false;
});
$('#file_show_mainarea_edit_file_button').button().click (function() {
$('#file_show_mainarea_edit_file_form_div').dialog('open');
return false;
});
<?php endif; ?> <?php endif; ?>
render_wiki (); render_wiki ();
@ -216,6 +509,36 @@ $this->load->view (
<div id="file_show_mainarea_result"> <div id="file_show_mainarea_result">
<div id='file_show_mainarea_files' class='collapsible-box'>
<div id='file_show_mainarea_files_header' class='collapsible-box-header'><?php print $this->lang->line('Files')?></div>
<div id='file_show_mainarea_files_body'>
<?php if (isset($login['id']) && $login['id'] != ''): ?>
<div>
<a id="file_show_mainarea_add_file_button" href='#'><?php print $this->lang->line('Add')?></a>
<a id="file_show_mainarea_edit_file_button" href='#'><?php print $this->lang->line('Edit')?></a>
</div>
<?php endif; ?>
<table>
<?php
for ($i = 0; $i < $file_count; $i++)
{
$f = $file->file_list[$i];
$xname = $this->converter->AsciiToHex($f->filename);
print '<tr><td>';
print anchor ("file/get/{$project->id}/{$xname}", htmlspecialchars($f->filename));
print '</td><td>';
print htmlspecialchars($f->description);
print '</td><td>';
print " <tt>{$f->md5sum}</tt>";
print '</td></tr>';
}
?>
</table>
</div>
</div>
<div class="result" id="file_show_mainarea_wiki"> <div class="result" id="file_show_mainarea_wiki">
<pre id="file_show_mainarea_wiki_text" style="visibility: hidden"> <pre id="file_show_mainarea_wiki_text" style="visibility: hidden">
@ -223,38 +546,13 @@ $this->load->view (
</pre> </pre>
</div> <!-- file_show_mainarea_wiki --> </div> <!-- file_show_mainarea_wiki -->
<div id="file_show_mainarea_result_info" class="infobox"> <div id="file_show_mainarea_result_info" class="infobox">
<ul> <ul>
<li><?php print $this->lang->line('Created on')?> <?php print $file->createdon ?></li> <li><?php print $this->lang->line('Created on')?> <?php print $file->createdon ?></li>
<li><?php print $this->lang->line('Created by')?> <?php print $file->createdby ?></li> <li><?php print $this->lang->line('Created by')?> <?php print $file->createdby ?></li>
<li><?php print $this->lang->line('Last updated on')?> <?php print $file->updatedon ?></li> <li><?php print $this->lang->line('Last updated on')?> <?php print $file->updatedon ?></li>
<li><?php print $this->lang->line('Last updated by')?> <?php print $file->updatedby ?></li> <li><?php print $this->lang->line('Last updated by')?> <?php print $file->updatedby ?></li>
</ul> </ul>
<div class="title"><?php print $this->lang->line('Files')?></div>
<?php if (isset($login['id']) && $login['id'] != ''): ?>
<!--
<div>
<a id="file_show_mainarea_add_file_button" href='#'><?php print $this->lang->line('Add')?></a>
<a id="file_show_mainarea_delete_file_button" href='#'><?php print $this->lang->line('Delete')?></a>
</div>
-->
<?php endif; ?>
<ul>
<?php
foreach ($file->file_list as $f)
{
$xname = $this->converter->AsciiToHex($f->filename);
print '<li>';
print anchor ("file/get/{$project->id}/{$xname}", $f->filename);
print " <tt>{$f->md5sum}</tt>";
print '</li>';
}
?>
</ul>
</div> <!-- file_show_mainarea_result_info --> </div> <!-- file_show_mainarea_result_info -->
</div> <!-- file_show_mainarea_result --> </div> <!-- file_show_mainarea_result -->
@ -267,6 +565,31 @@ $this->load->view (
<?php print $this->lang->line('MSG_SURE_TO_DELETE_THIS') . ' - ' . htmlspecialchars($file->name); ?> <?php print $this->lang->line('MSG_SURE_TO_DELETE_THIS') . ' - ' . htmlspecialchars($file->name); ?>
</div> </div>
<div id='file_show_mainarea_add_file_form_div'>
<div id='file_show_mainarea_add_file_input'>
<input type='file' id='file_show_mainarea_add_files' name='file_show_add_files' multiple='' autocomplete='off' style='color: transparent;' />
<table id='file_show_mainarea_add_file_table'></table>
</div>
</div>
<div id='file_show_mainarea_edit_file_form_div'>
<table>
<?php
for ($i = 0; $i < $file_count; $i++)
{
$f = $file->file_list[$i];
print '<tr><td>';
printf ('<a href="#" onClick="kill_edit_file(%d); return false;"><i class="fa fa-trash"></i></a>', $i);
print '</td><td>';
printf ('<span id="file_show_mainarea_edit_file_name_%d">%s</span>', $i, htmlspecialchars($f->filename));
print '</td><td>';
printf ('<input type="text" id="file_show_mainarea_edit_file_desc_%d" value="%s" size="40" autocomplete="off" />', $i, addslashes($f->description));
print '</td></tr>';
}
?>
</table>
</div>
<?php endif; ?> <?php endif; ?>
<div id='file_show_mainarea_alert'></div> <div id='file_show_mainarea_alert'></div>

View File

@ -196,7 +196,7 @@ $this->load->view (
if ($log['type'] == 'code') if ($log['type'] == 'code')
{ {
print '<td class="object">'; print '<td class="object">';
print anchor ( print anchor (
"code/revision/{$log['projectid']}/{$xdot}/{$code['rev']}", "code/revision/{$log['projectid']}/{$xdot}/{$code['rev']}",
"r{$code['rev']}"); "r{$code['rev']}");
print '</td>'; print '</td>';
@ -261,7 +261,7 @@ $this->load->view (
$trimmed = $this->lang->line('Issue') . " {$log['message']}"; $trimmed = $this->lang->line('Issue') . " {$log['message']}";
} }
if ($uri != '') if ($uri != '' && $trimmed != '')
{ {
print anchor ( print anchor (
$uri, $uri,
@ -276,10 +276,7 @@ $this->load->view (
$fmt = $this->lang->line ( $fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY'); 'MSG_LOG_'.strtoupper($log['action']).'_BY');
//print htmlspecialchars (sprintf($fmt, $log['userid'])); printf ($fmt, anchor ("/site/userlog/{$log['userid']}", htmlspecialchars($log['userid'])));
printf (
htmlspecialchars ($fmt),
anchor ("/site/userlog/{$log['userid']}", htmlspecialchars ($log['userid'])));
print '</span>'; print '</span>';
} }

View File

@ -245,7 +245,7 @@ foreach ($latest_projects as $project)
$trimmed = $this->lang->line('Issue') . " {$log['message']}"; $trimmed = $this->lang->line('Issue') . " {$log['message']}";
} }
if ($uri != '') if ($uri != '' && $trimmed != '')
print anchor ($uri, htmlspecialchars($trimmed)); print anchor ($uri, htmlspecialchars($trimmed));
else else
print htmlspecialchars($trimmed); print htmlspecialchars($trimmed);

View File

@ -38,13 +38,15 @@ function render_wiki()
if (isNaN(x_column_count) || x_column_count < 1) x_column_count = 1; if (isNaN(x_column_count) || x_column_count < 1) x_column_count = 1;
else if (x_column_count > 9) x_column_count = 9; // sync this max value with wiki_edit. TODO: put this into codepot.ini else if (x_column_count > 9) x_column_count = 9; // sync this max value with wiki_edit. TODO: put this into codepot.ini
column_count = x_column_count.toString(); if (x_column_count > 1)
{
$("#wiki_show_mainarea_wiki").css ({ column_count = x_column_count.toString();
"-moz-column-count": column_count, $("#wiki_show_mainarea_wiki").css ({
"-webkit-column-count": column_count, "-moz-column-count": column_count,
"column-count": column_count "-webkit-column-count": column_count,
}); "column-count": column_count
});
}
creole_render_wiki ( creole_render_wiki (
"wiki_show_mainarea_wiki_text", "wiki_show_mainarea_wiki_text",