enhanced the edit button in the file view.

fixed some issues handling page or image references
This commit is contained in:
hyung-hwan 2015-12-30 07:30:49 +00:00
parent d41ae391a1
commit a5c6ebbc1c
14 changed files with 737 additions and 266 deletions

View File

@ -237,6 +237,8 @@ class File extends Controller
} }
} }
/*
// DEPRECATED
function update ($projectid = '', $name = '') function update ($projectid = '', $name = '')
{ {
$this->load->helper ('form'); $this->load->helper ('form');
@ -288,6 +290,7 @@ class File extends Controller
if ($this->input->post('file')) if ($this->input->post('file'))
{ {
$file = new stdClass();
$file->name = $this->input->post('file_name'); $file->name = $this->input->post('file_name');
$file->tag = $this->input->post('file_tag'); $file->tag = $this->input->post('file_tag');
$file->description = $this->input->post('file_description'); $file->description = $this->input->post('file_description');
@ -334,6 +337,7 @@ class File extends Controller
} }
} }
} }
*/
function xhr_import ($projectid = '') function xhr_import ($projectid = '')
{ {
@ -602,6 +606,72 @@ class File extends Controller
print $status; print $status;
} }
function xhr_update ($projectid = '', $name = '')
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('FileModel', 'files');
$login = $this->login->getUser ();
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
{
$file = new stdClass();
$file->name = $this->input->post('file_edit_name');
$file->tag = $this->input->post('file_edit_tag');
$file->description = $this->input->post('file_edit_description');
if ($file->name === FALSE || ($file->name = trim($file->name)) == '')
{
$status = 'error - no name';
}
else if ($file->tag === FALSE || ($file->tag = trim($file->tag)) == '')
{
$status = 'error - no tag';
}
else if ($file->description === FALSE || ($file->description = trim($file->description)) == '')
{
$status = 'error - no description';
}
else
{
if ($this->files->update ($login['id'], $projectid, $name, $file) === FALSE)
{
$status = 'error - ' . $this->files->getErrorMessage();
}
else
{
$status = 'ok';
}
}
}
}
print $status;
}
function xhr_delete ($projectid = '', $name = '') function xhr_delete ($projectid = '', $name = '')
{ {
$this->load->model ('ProjectModel', 'projects'); $this->load->model ('ProjectModel', 'projects');

View File

@ -918,7 +918,100 @@ DEPRECATED
print $status; print $status;
} }
private function _handle_file ($login, $projectid, $issueid, $filename) ////////////////////////////////////////////////////////////////////////
// Handling of attached files share the (almost) same code
// between issue.php and wiki.php. It would be way better
// to put the common code into a parent class and use inheritance.
// Makre sure to apply changes to both files if any.
private function _handle_wiki_attachment ($login, $projectid, $wikiname, $name)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('WikiModel', 'wikis');
$data['login'] = $login;
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($project === NULL)
{
$data['message'] =
$this->lang->line('MSG_NO_SUCH_PROJECT') .
" - {$projectid}";
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
if ($project->public !== 'Y' && $login['id'] == '')
{
// non-public projects require sign-in.
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
}
$att = $this->wikis->getAttachment ($login['id'], $project, $wikiname, $name);
if ($att === FALSE)
{
$data['project'] = $project;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($att === NULL)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_NO_SUCH_FILE'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
$path = CODEPOT_ATTACHMENT_DIR . "/{$att->encname}";
$stat = @stat($path);
if ($stat === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_FAILED_TO_READ_FILE'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']);
$lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']);
header ('Last-Modified: ' . $lastmod . ' GMT');
header ('Etag: ' . $etag);
if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) ||
(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime']))
{
header('Not Modified', true, 304);
flush ();
return;
}
header ('Content-Type: ' . mime_content_type($path));
header ('Content-Length: ' . $stat['size']);
header ('Content-Disposition: inline; filename=' . $name);
flush ();
$x = @readfile($path);
if ($x === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_FAILED_TO_READ_FILE'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
}
}
}
}
private function _handle_issue_file ($login, $projectid, $issueid, $filename)
{ {
$this->load->model ('ProjectModel', 'projects'); $this->load->model ('ProjectModel', 'projects');
$this->load->model ('IssueModel', 'issues'); $this->load->model ('IssueModel', 'issues');
@ -957,7 +1050,7 @@ DEPRECATED
{ {
$data['project'] = $project; $data['project'] = $project;
$data['message'] = sprintf ( $data['message'] = sprintf (
$this->lang->line('ISSUE_MSG_NO_SUCH_FILE'), $filename); $this->lang->line('MSG_NO_SUCH_FILE'), $filename);
$this->load->view ($this->VIEW_ERROR, $data); $this->load->view ($this->VIEW_ERROR, $data);
} }
else else
@ -969,7 +1062,7 @@ DEPRECATED
{ {
$data['project'] = $project; $data['project'] = $project;
$data['message'] = sprintf ( $data['message'] = sprintf (
$this->lang->line('issue_MSG_FAILED_TO_READ_FILE'), $filename); $this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename);
$this->load->view ($this->VIEW_ERROR, $data); $this->load->view ($this->VIEW_ERROR, $data);
return; return;
} }
@ -998,7 +1091,7 @@ DEPRECATED
{ {
$data['project'] = $project; $data['project'] = $project;
$data['message'] = sprintf ( $data['message'] = sprintf (
$this->lang->line('ISSUE_MSG_FAILED_TO_READ_FILE'), $filename); $this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename);
$this->load->view ($this->VIEW_ERROR, $data); $this->load->view ($this->VIEW_ERROR, $data);
} }
} }
@ -1007,6 +1100,11 @@ DEPRECATED
function file ($projectid = '', $issueid = '', $filename = '') function file ($projectid = '', $issueid = '', $filename = '')
{ {
// this function is for handling a file name for the following format:
// 1. filename
// 2. projectid:issueid:filename
// 3. projectid:wikiname:filename
//
$login = $this->login->getUser (); $login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
@ -1021,40 +1119,30 @@ DEPRECATED
$filename = $this->converter->HexToAscii ($filename); $filename = $this->converter->HexToAscii ($filename);
$wikiname = '';
$part = explode (':', $filename); $part = explode (':', $filename);
if (count($part) == 3) if (count($part) == 3)
{ {
if ($part[0] != '') $projectid = $part[0]; if ($part[0] != '') $projectid = $part[0];
if ($part[1] != '') $issueid = $part[1]; if ($part[1] != '')
{
if ($part[1][0] == '#' && $part[1][1] == 'I')
{
$issueid = substr ($part[1],2);
$wikiname = '';
}
else
{
$wikiname = $part[1];
$issueid = '';
}
}
if ($part[2] != '') $filename = $part[2]; if ($part[2] != '') $filename = $part[2];
} }
$this->_handle_file ($login, $projectid, $issueid, $filename); if ($wikiname != '')
} $this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename);
else
$this->_handle_issue_file ($login, $projectid, $issueid, $filename);
function file0 ($projectid = '', $target = '')
{
//$target => projectid:issueid:filename
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
if ($target == '')
{
$data['login'] = $login;
$data['message'] = 'INVALID PARAMETERS';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$target = $this->converter->HexToAscii ($target);
$part = explode (':', $target);
if (count($part) == 3)
{
if ($part[0] == '') $part[0] = $projectid;
$this->_handle_attachment ($login, $part[0], $part[1], $part[2]);
}
} }
} }

View File

@ -175,147 +175,6 @@ class Wiki extends Controller
$this->_show_wiki ($projectid, $name, FALSE); $this->_show_wiki ($projectid, $name, FALSE);
} }
function attachment0 ($projectid = '', $target = '')
{
//$target => projectid:wikiname:attachment
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
if ($target == '')
{
$data['login'] = $login;
$data['message'] = 'INVALID PARAMETERS';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$target = $this->converter->HexToAscii ($target);
$part = explode (':', $target);
if (count($part) == 3)
{
if ($part[0] == '') $part[0] = $projectid;
$this->_handle_attachment ($login, $part[0], $part[1], $part[2]);
}
}
function attachment ($projectid = '', $wikiname = '', $name = '')
{
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
if ($wikiname == '' || $name == '')
{
$data['login'] = $login;
$data['message'] = 'INVALID PARAMETERS';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$wikiname = $this->converter->HexToAscii ($wikiname);
$name = $this->converter->HexToAscii ($name);
$part = explode (':', $name);
if (count($part) == 3)
{
if ($part[0] != '') $projectid = $part[0];
if ($part[1] != '') $wikiname = $part[1];
if ($part[2] != '') $name = $part[2];
}
$this->_handle_attachment ($login, $projectid, $wikiname, $name);
}
private function _handle_attachment ($login, $projectid, $wikiname, $name)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('WikiModel', 'wikis');
$data['login'] = $login;
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($project === NULL)
{
$data['message'] =
$this->lang->line('MSG_NO_SUCH_PROJECT') .
" - {$projectid}";
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
if ($project->public !== 'Y' && $login['id'] == '')
{
// non-public projects require sign-in.
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
}
$att = $this->wikis->getAttachment ($login['id'], $project, $wikiname, $name);
if ($att === FALSE)
{
$data['project'] = $project;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($att === NULL)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('WIKI_MSG_NO_SUCH_ATTACHMENT'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
$path = CODEPOT_ATTACHMENT_DIR . "/{$att->encname}";
$stat = @stat($path);
if ($stat === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('WIKI_MSG_FAILED_TO_READ_ATTACHMENT'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']);
$lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']);
header ('Last-Modified: ' . $lastmod . ' GMT');
header ('Etag: ' . $etag);
if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) ||
(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime']))
{
header('Not Modified', true, 304);
flush ();
return;
}
header ('Content-Type: ' . mime_content_type($path));
header ('Content-Length: ' . $stat['size']);
header ('Content-Disposition: inline; filename=' . $name);
flush ();
$x = @readfile($path);
if ($x === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('WIKI_MSG_FAILED_TO_READ_ATTACHMENT'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
}
}
}
}
function _edit_wiki ($projectid, $name, $mode) function _edit_wiki ($projectid, $name, $mode)
{ {
$this->load->helper ('form'); $this->load->helper ('form');
@ -377,6 +236,7 @@ class Wiki extends Controller
if ($this->input->post('wiki')) if ($this->input->post('wiki'))
{ {
$wiki = new stdClass();
$wiki->projectid = $this->input->post('wiki_projectid'); $wiki->projectid = $this->input->post('wiki_projectid');
if ($mode == 'update') if ($mode == 'update')
{ {
@ -542,6 +402,7 @@ class Wiki extends Controller
} }
else else
{ {
$wiki = new stdClass();
$wiki->projectid = $projectid; $wiki->projectid = $projectid;
$wiki->name = $name; $wiki->name = $name;
$wiki->text = ''; $wiki->text = '';
@ -623,6 +484,7 @@ class Wiki extends Controller
if($this->input->post('wiki')) if($this->input->post('wiki'))
{ {
$wiki = new stdClass();
$wiki->projectid = $this->input->post('wiki_projectid'); $wiki->projectid = $this->input->post('wiki_projectid');
$wiki->name = $this->input->post('wiki_name'); $wiki->name = $this->input->post('wiki_name');
$data['wiki_confirm'] = $this->input->post('wiki_confirm'); $data['wiki_confirm'] = $this->input->post('wiki_confirm');
@ -738,4 +600,262 @@ class Wiki extends Controller
return array(TRUE,$attachments); return array(TRUE,$attachments);
} }
///////////////////////////////////////////////////////////////////////
// Handling of attached files share the (almost) same code
// between issue.php and wiki.php. It would be way better
// to put the common code into a parent class and use inheritance.
// Makre sure to apply changes to both files if any.
private function _handle_wiki_attachment ($login, $projectid, $wikiname, $name)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('WikiModel', 'wikis');
$data['login'] = $login;
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($project === NULL)
{
$data['message'] =
$this->lang->line('MSG_NO_SUCH_PROJECT') .
" - {$projectid}";
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
if ($project->public !== 'Y' && $login['id'] == '')
{
// non-public projects require sign-in.
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
}
$att = $this->wikis->getAttachment ($login['id'], $project, $wikiname, $name);
if ($att === FALSE)
{
$data['project'] = $project;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($att === NULL)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_NO_SUCH_FILE'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
$path = CODEPOT_ATTACHMENT_DIR . "/{$att->encname}";
$stat = @stat($path);
if ($stat === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_FAILED_TO_READ_FILE'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']);
$lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']);
header ('Last-Modified: ' . $lastmod . ' GMT');
header ('Etag: ' . $etag);
if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) ||
(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime']))
{
header('Not Modified', true, 304);
flush ();
return;
}
header ('Content-Type: ' . mime_content_type($path));
header ('Content-Length: ' . $stat['size']);
header ('Content-Disposition: inline; filename=' . $name);
flush ();
$x = @readfile($path);
if ($x === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_FAILED_TO_READ_FILE'), $name);
$this->load->view ($this->VIEW_ERROR, $data);
}
}
}
}
private function _handle_issue_file ($login, $projectid, $issueid, $filename)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('IssueModel', 'issues');
$data['login'] = $login;
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($project === NULL)
{
$data['message'] =
$this->lang->line('MSG_NO_SUCH_PROJECT') .
" - {$projectid}";
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
if ($project->public !== 'Y' && $login['id'] == '')
{
// non-public projects require sign-in.
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
}
$att = $this->issues->getFile ($login['id'], $project, $issueid, $filename);
if ($att === FALSE)
{
$data['project'] = $project;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else if ($att === NULL)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_NO_SUCH_FILE'), $filename);
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
$path = CODEPOT_ISSUE_FILE_DIR . "/{$att->encname}";
$stat = @stat($path);
if ($stat === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename);
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']);
$lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']);
header ('Last-Modified: ' . $lastmod . ' GMT');
header ('Etag: ' . $etag);
if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) ||
(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime']))
{
header('Not Modified', true, 304);
flush ();
return;
}
header ('Content-Type: ' . mime_content_type($path));
header ('Content-Length: ' . $stat['size']);
header ('Content-Disposition: inline; filename=' . $filename);
flush ();
$x = @readfile($path);
if ($x === FALSE)
{
$data['project'] = $project;
$data['message'] = sprintf (
$this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename);
$this->load->view ($this->VIEW_ERROR, $data);
}
}
}
}
function attachment0 ($projectid = '', $target = '')
{
//$target => projectid:wikiname:attachment
//$target => projectid:#I1:file
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
if ($target == '')
{
$data['login'] = $login;
$data['message'] = 'INVALID PARAMETERS';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$target = $this->converter->HexToAscii ($target);
$part = explode (':', $target);
if (count($part) == 3)
{
if ($part[0] == '') $part[0] = $projectid;
if ($part[1][0] == '#' && $part[1][1] == 'I')
{
$issueid = substr ($part[1],2);
$this->_handle_issue_file ($login, $part[0], $issueid, $part[2]);
}
else
{
$this->_handle_wiki_attachment ($login, $part[0], $part[1], $part[2]);
}
}
}
function attachment ($projectid = '', $wikiname = '', $filename = '')
{
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
if ($wikiname == '' || $filename == '')
{
$data['login'] = $login;
$data['message'] = 'INVALID PARAMETERS';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$wikiname = $this->converter->HexToAscii ($wikiname);
$filename = $this->converter->HexToAscii ($filename);
$part = explode (':', $filename);
if (count($part) == 3)
{
if ($part[0] != '') $projectid = $part[0];
if ($part[1] != '')
{
if ($part[1][0] == '#' && $part[1][1] == 'I')
{
$issueid = substr ($part[1],2);
$wikiname = '';
}
else
{
$wikiname = $part[1];
$issueid = '';
}
}
if ($part[2] != '') $filename = $part[2];
}
if ($wikiname != '')
$this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename);
else
$this->_handle_issue_file ($login, $projectid, $issueid, $filename);
}
} }

View File

@ -126,6 +126,8 @@ $lang['MSG_NO_DIFF'] = 'No difference found';
$lang['MSG_NO_CODE_AVAIL'] = 'No source code available'; $lang['MSG_NO_CODE_AVAIL'] = 'No source code available';
$lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_NO_SUCH_PROJECT'] = 'No such project';
$lang['MSG_SURE_TO_DELETE_THIS'] = "I'm sure to delete this"; $lang['MSG_SURE_TO_DELETE_THIS'] = "I'm sure to delete this";
$lang['MSG_FAILED_TO_READ_FILE'] = 'Failed to read file - %s';
$lang['MSG_NO_SUCH_FILE'] = 'No such file - %s';
$lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task';
$lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete';

View File

@ -4,10 +4,8 @@ $lang['WIKI_NEW_ATTACHMENTS'] = 'New attachments';
$lang['WIKI_MORE_NEW_ATTACHMENTS'] = 'Add more'; $lang['WIKI_MORE_NEW_ATTACHMENTS'] = 'Add more';
$lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = 'Attachment name containing a colon'; $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = 'Attachment name containing a colon';
$lang['WIKI_MSG_FAILED_TO_READ_ATTACHMENT'] = 'Failed to read wiki attachment - %s';
$lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = 'Wiki name contains disallowed characters'; $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = 'Wiki name contains disallowed characters';
$lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = 'No wiki pages available'; $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = 'No wiki pages available';
$lang['WIKI_MSG_NO_SUCH_PAGE'] = 'No such wiki page - %s'; $lang['WIKI_MSG_NO_SUCH_PAGE'] = 'No such wiki page - %s';
$lang['WIKI_MSG_NO_SUCH_ATTACHMENT'] = 'No such wiki attachment - %s';
$lang['WIKI_MSG_RESERVED_WIKI_NAME'] = 'Wiki name containing a reserved word - %s'; $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = 'Wiki name containing a reserved word - %s';
?> ?>

View File

@ -123,6 +123,8 @@ $lang['MSG_NO_DIFF'] = 'Tidak ada bedanya';
$lang['MSG_NO_CODE_AVAIL'] = 'Tidak ada kode sumber tersedia'; $lang['MSG_NO_CODE_AVAIL'] = 'Tidak ada kode sumber tersedia';
$lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_NO_SUCH_PROJECT'] = 'No such project';
$lang['MSG_SURE_TO_DELETE_THIS'] = "Saya yakin untuk menghapus"; $lang['MSG_SURE_TO_DELETE_THIS'] = "Saya yakin untuk menghapus";
$lang['MSG_FAILED_TO_READ_FILE'] = 'Failed to read file - %s';
$lang['MSG_NO_SUCH_FILE'] = 'No such file - %s';
$lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task';
$lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete';

View File

@ -126,6 +126,8 @@ $lang['MSG_NO_DIFF'] = '차이점이 없습니다';
$lang['MSG_NO_CODE_AVAIL'] = '소스코드가 없습니다'; $lang['MSG_NO_CODE_AVAIL'] = '소스코드가 없습니다';
$lang['MSG_NO_SUCH_PROJECT'] = '프로젝트가 없습니다'; $lang['MSG_NO_SUCH_PROJECT'] = '프로젝트가 없습니다';
$lang['MSG_SURE_TO_DELETE_THIS'] = '반드시 이것을 삭제하고 싶어요'; $lang['MSG_SURE_TO_DELETE_THIS'] = '반드시 이것을 삭제하고 싶어요';
$lang['MSG_FAILED_TO_READ_FILE'] = '파일을 읽을 수 없습니다 - %s';
$lang['MSG_NO_SUCH_FILE'] = '파일이 없습니다 - %s';
$lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = '이 작업을 수행하려면 %s 프로젝트의 멤버가 되어야 합니다'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = '이 작업을 수행하려면 %s 프로젝트의 멤버가 되어야 합니다';
$lang['MSG_FORM_INPUT_INCOMPLETE'] = '입력이 완전하지 않습니다'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = '입력이 완전하지 않습니다';

View File

@ -4,10 +4,8 @@ $lang['WIKI_NEW_ATTACHMENTS'] = '새로운 첨부파일';
$lang['WIKI_MORE_NEW_ATTACHMENTS'] = '첨부파일 추가'; $lang['WIKI_MORE_NEW_ATTACHMENTS'] = '첨부파일 추가';
$lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = '첨부파일이름에 콜론기호를 포함할 수 없습니다'; $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = '첨부파일이름에 콜론기호를 포함할 수 없습니다';
$lang['WIKI_MSG_FAILED_TO_READ_ATTACHMENT'] = '위키 첨부파일을 읽을 수 없습니다 - %s';
$lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = '위키이름에 허용되지 않는 문자가 포함되어 있습니다'; $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = '위키이름에 허용되지 않는 문자가 포함되어 있습니다';
$lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = '사용할 수 있는 위키 페이지가 없습니다'; $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = '사용할 수 있는 위키 페이지가 없습니다';
$lang['WIKI_MSG_NO_SUCH_PAGE'] = '위키 페이지를 찾을수 없습니다 - %s'; $lang['WIKI_MSG_NO_SUCH_PAGE'] = '위키 페이지를 찾을수 없습니다 - %s';
$lang['WIKI_MSG_NO_SUCH_ATTACHMENT'] = '위키 첨부파일을 찾을 수 없습니다 - %s';
$lang['WIKI_MSG_RESERVED_WIKI_NAME'] = '%s은(는) 사용할 수 없는 위키이름입니다'; $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = '%s은(는) 사용할 수 없는 위키이름입니다';
?> ?>

View File

@ -135,7 +135,7 @@ class FileModel extends Model
} }
*/ */
function update ($userid, $projectid, $name, $file) private function _update_file ($userid, $projectid, $name, $file)
{ {
$this->db->trans_start (); $this->db->trans_start ();
@ -176,6 +176,15 @@ class FileModel extends Model
return $this->db->trans_status(); return $this->db->trans_status();
} }
function update ($userid, $projectid, $name, $file)
{
set_error_handler (array ($this, 'capture_error'));
$errmsg = '';
$x = $this->_update_file ($userid, $projectid, $name, $file);
restore_error_handler ();
return $x;
}
private function _delete_file ($userid, $projectid, $name) private function _delete_file ($userid, $projectid, $name)
{ {
$this->db->trans_begin (); // manual transaction. not using trans_start(). $this->db->trans_begin (); // manual transaction. not using trans_start().

View File

@ -43,7 +43,7 @@ class LoginModel extends Model
{ {
$settings = @unserialize ($settings); $settings = @unserialize ($settings);
if ($settings === FALSE || $settings === NULL) if ($settings === FALSE || $settings === NULL)
$settings = new stdObject(); $settings = new stdClass();
// Sanity check on the session/cookie data // Sanity check on the session/cookie data
// See Controller/User->settings() for required fields. // See Controller/User->settings() for required fields.

View File

@ -26,6 +26,9 @@
<?php <?php
$hexname = $this->converter->AsciiToHex ($file->name); $hexname = $this->converter->AsciiToHex ($file->name);
$file_count = count ($file->file_list); $file_count = count ($file->file_list);
$creole_base = site_url() . "/wiki/show/{$project->id}/";
$creole_file_base = site_url() . "/wiki/attachment0/{$project->id}/";
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -50,8 +53,20 @@ function render_wiki()
creole_render_wiki ( creole_render_wiki (
"file_show_mainarea_wiki_text", "file_show_mainarea_wiki_text",
"file_show_mainarea_wiki", "file_show_mainarea_wiki",
"<?php print site_url()?>/wiki/show/<?php print $project->id?>/", "<?php print $creole_base; ?>",
"<?php print site_url()?>/wiki/attachment0/<?php print $project->id?>/" "<?php print $creole_file_base; ?>/"
);
prettyPrint ();
}
function preview_edit_description (input_text)
{
creole_render_wiki_with_input_text (
input_text,
"file_show_mainarea_edit_description_preview",
"<?php print $creole_base; ?>",
"<?php print $creole_file_base; ?>/"
); );
prettyPrint (); prettyPrint ();
@ -126,9 +141,7 @@ function kill_edit_file (no)
} }
} }
var delete_in_progress = false; var work_in_progress = false;
var add_file_in_progress = false;
var edit_file_in_progress = false;
var original_file_name = [ var original_file_name = [
<?php <?php
@ -182,7 +195,94 @@ $(function () {
<?php if (isset($login['id']) && $login['id'] != ''): ?> <?php if (isset($login['id']) && $login['id'] != ''): ?>
$('#file_show_mainarea_delete_form_div').dialog ( $('#file_show_mainarea_edit_description_tabs').tabs ();
$('#file_show_mainarea_edit_description_tabs').bind ('tabsshow', function (event, ui) {
if (ui.index == 1) preview_edit_description ($('#file_show_mainarea_edit_description').val());
});
$('#file_show_mainarea_edit_form').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 (work_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
work_in_progress = true;
var form_data = new FormData();
var new_name = $('#file_show_mainarea_edit_name').val()
form_data.append ('file_edit_name', new_name);
form_data.append ('file_edit_tag', $('#file_show_mainarea_edit_tag').val());
form_data.append ('file_edit_description', $('#file_show_mainarea_edit_description').val());
$('#file_show_mainarea_edit_form').dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_update/{$project->id}/{$hexname}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
work_in_progress = false;
$('#file_show_mainarea_edit_form').dialog('enable');
$('#file_show_mainarea_edit_form').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}/"; ?>' + codepot_ascii_to_hex(new_name)));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
work_in_progress = false;
$('#file_show_mainarea_edit_form').dialog('enable');
$('#file_show_mainarea_edit_form').dialog('close');
var errmsg = '';
if (errmsg == '' && errorThrown != null) errmsg = errorThrown;
if (errmsg == '' && textStatus != null) errmsg = textStatus;
if (errmsg == '') errmsg = 'Unknown error';
show_alert ('Failed - ' + errmsg, "<?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 (work_in_progress) return;
$('#file_show_mainarea_edit_form').dialog('close');
}
},
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !work_in_progress;
}
}
);
$('#file_show_mainarea_delete_form').dialog (
{ {
title: '<?php print $this->lang->line('Delete');?>', title: '<?php print $this->lang->line('Delete');?>',
resizable: true, resizable: true,
@ -192,19 +292,19 @@ $(function () {
modal: true, modal: true,
buttons: { buttons: {
'<?php print $this->lang->line('OK')?>': function () { '<?php print $this->lang->line('OK')?>': function () {
if (delete_in_progress) return; if (work_in_progress) return;
if (!!window.FormData) if (!!window.FormData)
{ {
// FormData is supported // FormData is supported
delete_in_progress = true; work_in_progress = true;
var form_data = new FormData(); var form_data = new FormData();
var f = $('#file_show_mainarea_delete_confirm'); var f = $('#file_show_mainarea_delete_confirm');
if (f != null && f.is(':checked')) form_data.append ('file_delete_confirm', 'Y'); if (f != null && f.is(':checked')) form_data.append ('file_delete_confirm', 'Y');
$('#file_show_mainarea_delete_form_div').dialog('disable'); $('#file_show_mainarea_delete_form').dialog('disable');
$.ajax({ $.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_delete/{$project->id}/{$hexname}"; ?>'), url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_delete/{$project->id}/{$hexname}"; ?>'),
type: 'POST', type: 'POST',
@ -215,9 +315,9 @@ $(function () {
cache: false, cache: false,
success: function (data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {
delete_in_progress = false; work_in_progress = false;
$('#file_show_mainarea_delete_form_div').dialog('enable'); $('#file_show_mainarea_delete_form').dialog('enable');
$('#file_show_mainarea_delete_form_div').dialog('close'); $('#file_show_mainarea_delete_form').dialog('close');
if (data == 'ok') if (data == 'ok')
{ {
// refresh the page to the head revision // refresh the page to the head revision
@ -230,9 +330,9 @@ $(function () {
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
delete_in_progress = false; work_in_progress = false;
$('#file_show_mainarea_delete_form_div').dialog('enable'); $('#file_show_mainarea_delete_form').dialog('enable');
$('#file_show_mainarea_delete_form_div').dialog('close'); $('#file_show_mainarea_delete_form').dialog('close');
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>"); show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
} }
}); });
@ -243,15 +343,15 @@ $(function () {
} }
}, },
'<?php print $this->lang->line('Cancel')?>': function () { '<?php print $this->lang->line('Cancel')?>': function () {
if (delete_in_progress) return; if (work_in_progress) return;
$('#file_show_mainarea_delete_form_div').dialog('close'); $('#file_show_mainarea_delete_form').dialog('close');
} }
}, },
beforeClose: function() { beforeClose: function() {
// if importing is in progress, prevent dialog closing // if importing is in progress, prevent dialog closing
return !delete_in_progress; return !work_in_progress;
} }
} }
); );
@ -260,7 +360,7 @@ $(function () {
populate_selected_files_for_adding (); populate_selected_files_for_adding ();
}); });
$('#file_show_mainarea_add_file_form_div').dialog ( $('#file_show_mainarea_add_file_form').dialog (
{ {
title: '<?php print $this->lang->line('Add');?>', title: '<?php print $this->lang->line('Add');?>',
resizable: true, resizable: true,
@ -270,12 +370,12 @@ $(function () {
modal: true, modal: true,
buttons: { buttons: {
'<?php print $this->lang->line('OK')?>': function () { '<?php print $this->lang->line('OK')?>': function () {
if (add_file_in_progress) return; if (work_in_progress) return;
if (!!window.FormData) if (!!window.FormData)
{ {
// FormData is supported // FormData is supported
add_file_in_progress = true; work_in_progress = true;
var form_data = new FormData(); var form_data = new FormData();
@ -294,7 +394,7 @@ $(function () {
} }
form_data.append ('file_add_file_count', f_no); form_data.append ('file_add_file_count', f_no);
$('#file_show_mainarea_add_file_form_div').dialog('disable'); $('#file_show_mainarea_add_file_form').dialog('disable');
$.ajax({ $.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_add_file/{$project->id}/{$hexname}"; ?>'), url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_add_file/{$project->id}/{$hexname}"; ?>'),
type: 'POST', type: 'POST',
@ -305,9 +405,9 @@ $(function () {
cache: false, cache: false,
success: function (data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {
add_file_in_progress = false; work_in_progress = false;
$('#file_show_mainarea_add_file_form_div').dialog('enable'); $('#file_show_mainarea_add_file_form').dialog('enable');
$('#file_show_mainarea_add_file_form_div').dialog('close'); $('#file_show_mainarea_add_file_form').dialog('close');
if (data == 'ok') if (data == 'ok')
{ {
// refresh the page to the head revision // refresh the page to the head revision
@ -320,9 +420,9 @@ $(function () {
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
add_file_in_progress = false; work_in_progress = false;
$('#file_show_mainarea_add_file_form_div').dialog('enable'); $('#file_show_mainarea_add_file_form').dialog('enable');
$('#file_show_mainarea_add_file_form_div').dialog('close'); $('#file_show_mainarea_add_file_form').dialog('close');
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>"); show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
} }
}); });
@ -333,20 +433,20 @@ $(function () {
} }
}, },
'<?php print $this->lang->line('Cancel')?>': function () { '<?php print $this->lang->line('Cancel')?>': function () {
if (add_file_in_progress) return; if (work_in_progress) return;
$('#file_show_mainarea_add_file_form_div').dialog('close'); $('#file_show_mainarea_add_file_form').dialog('close');
} }
}, },
beforeClose: function() { beforeClose: function() {
// if importing is in progress, prevent dialog closing // if importing is in progress, prevent dialog closing
return !add_file_in_progress; return !work_in_progress;
} }
} }
); );
$('#file_show_mainarea_edit_file_form_div').dialog ( $('#file_show_mainarea_edit_file_form').dialog (
{ {
title: '<?php print $this->lang->line('Edit');?>', title: '<?php print $this->lang->line('Edit');?>',
resizable: true, resizable: true,
@ -356,12 +456,12 @@ $(function () {
modal: true, modal: true,
buttons: { buttons: {
'<?php print $this->lang->line('OK')?>': function () { '<?php print $this->lang->line('OK')?>': function () {
if (edit_file_in_progress) return; if (work_in_progress) return;
if (!!window.FormData) if (!!window.FormData)
{ {
// FormData is supported // FormData is supported
edit_file_in_progress = true; work_in_progress = true;
var form_data = new FormData(); var form_data = new FormData();
@ -389,7 +489,7 @@ $(function () {
} }
form_data.append ('file_edit_file_count', f_no); form_data.append ('file_edit_file_count', f_no);
$('#file_show_mainarea_edit_file_form_div').dialog('disable'); $('#file_show_mainarea_edit_file_form').dialog('disable');
$.ajax({ $.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_edit_file/{$project->id}/{$hexname}"; ?>'), url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/file/xhr_edit_file/{$project->id}/{$hexname}"; ?>'),
type: 'POST', type: 'POST',
@ -400,9 +500,9 @@ $(function () {
cache: false, cache: false,
success: function (data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {
edit_file_in_progress = false; work_in_progress = false;
$('#file_show_mainarea_edit_file_form_div').dialog('enable'); $('#file_show_mainarea_edit_file_form').dialog('enable');
$('#file_show_mainarea_edit_file_form_div').dialog('close'); $('#file_show_mainarea_edit_file_form').dialog('close');
if (data == 'ok') if (data == 'ok')
{ {
// refresh the page to the head revision // refresh the page to the head revision
@ -415,9 +515,9 @@ $(function () {
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
edit_file_in_progress = false; work_in_progress = false;
$('#file_show_mainarea_edit_file_form_div').dialog('enable'); $('#file_show_mainarea_edit_file_form').dialog('enable');
$('#file_show_mainarea_edit_file_form_div').dialog('close'); $('#file_show_mainarea_edit_file_form').dialog('close');
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>"); show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
} }
}); });
@ -428,33 +528,45 @@ $(function () {
} }
}, },
'<?php print $this->lang->line('Cancel')?>': function () { '<?php print $this->lang->line('Cancel')?>': function () {
if (edit_file_in_progress) return; if (work_in_progress) return;
$('#file_show_mainarea_edit_file_form_div').dialog('close'); $('#file_show_mainarea_edit_file_form').dialog('close');
} }
}, },
beforeClose: function() { beforeClose: function() {
// if importing is in progress, prevent dialog closing // if importing is in progress, prevent dialog closing
return !edit_file_in_progress; return !work_in_progress;
} }
} }
); );
$('#file_show_mainarea_delete_button').button().click (function() { $('#file_show_mainarea_edit_button').button().click (
$('#file_show_mainarea_delete_form_div').dialog('open'); function () {
$('#file_show_mainarea_edit_form').dialog('open');
return false; // prevent the default behavior
}
);
$('#file_show_mainarea_delete_button').button().click (
function() {
$('#file_show_mainarea_delete_form').dialog('open');
return false; return false;
}); }
);
$('#file_show_mainarea_add_file_button').button().click (function() { $('#file_show_mainarea_add_file_button').button().click (
$('#file_show_mainarea_add_file_form_div').dialog('open'); function() {
$('#file_show_mainarea_add_file_form').dialog('open');
return false; return false;
}); }
);
$('#file_show_mainarea_edit_file_button').button().click (function() { $('#file_show_mainarea_edit_file_button').button().click (
$('#file_show_mainarea_edit_file_form_div').dialog('open'); function() {
$('#file_show_mainarea_edit_file_form').dialog('open');
return false; return false;
}); }
);
<?php endif; ?> <?php endif; ?>
render_wiki (); render_wiki ();
@ -488,7 +600,8 @@ $this->load->view (
), ),
'ctxmenuitems' => array ( 'ctxmenuitems' => array (
array ("file/update/{$project->id}/{$hexname}", '<i class="fa fa-edit"></i> ' . $this->lang->line('Edit')) // DEPRECATED
//array ("file/update/{$project->id}/{$hexname}", '<i class="fa fa-edit"></i> ' . $this->lang->line('Edit'))
) )
) )
); );
@ -502,6 +615,7 @@ $this->load->view (
<div class="infostrip" id="wiki_show_mainarea_infostrip"> <div class="infostrip" id="wiki_show_mainarea_infostrip">
<?php if (isset($login['id']) && $login['id'] != ''): ?> <?php if (isset($login['id']) && $login['id'] != ''): ?>
<a id="file_show_mainarea_edit_button" href='#'><?php print $this->lang->line('Edit')?></a>
<a id="file_show_mainarea_delete_button" href='#'><?php print $this->lang->line('Delete')?></a> <a id="file_show_mainarea_delete_button" href='#'><?php print $this->lang->line('Delete')?></a>
<?php endif; ?> <?php endif; ?>
<a id="file_show_mainarea_metadata_button" href='#'><?php print $this->lang->line('Metadata')?></a> <a id="file_show_mainarea_metadata_button" href='#'><?php print $this->lang->line('Metadata')?></a>
@ -560,19 +674,39 @@ $this->load->view (
<?php if (isset($login['id']) && $login['id'] != ''): ?> <?php if (isset($login['id']) && $login['id'] != ''): ?>
<div id='file_show_mainarea_delete_form_div'> <div id='file_show_mainarea_edit_form'>
<div style='line-height: 2em;'>
<?php print $this->lang->line('Tag'); ?>: <input type='text' id='file_show_mainarea_edit_tag' name='file_show_edit_tag' size='30' value='<?php print addslashes($file->tag); ?>'/>
<?php print $this->lang->line('Name'); ?>: <input type='text' id='file_show_mainarea_edit_name' name='file_show_edit_name' size='60' value='<?php print addslashes($file->name); ?>'/>
</div>
<div id='file_show_mainarea_edit_description_tabs' style='width:100%;'>
<ul>
<li><a href='#file_show_mainarea_edit_description_input'><?php print $this->lang->line('Description'); ?></a></li>
<li><a href='#file_show_mainarea_edit_description_preview'><?php print $this->lang->line('Preview'); ?></a></li>
</ul>
<div id='file_show_mainarea_edit_description_input'>
<textarea type='textarea' id='file_show_mainarea_edit_description' name='file_show_edit_description' rows=24 cols=100 style='width:100%;'><?php print htmlspecialchars($file->description); ?></textarea>
</div>
<div id='file_show_mainarea_edit_description_preview' class='form_input_preview'>
</div>
</div>
</div>
<div id='file_show_mainarea_delete_form'>
<input type='checkbox' id='file_show_mainarea_delete_confirm' /> <input type='checkbox' id='file_show_mainarea_delete_confirm' />
<?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_form'>
<div id='file_show_mainarea_add_file_input'> <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;' /> <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> <table id='file_show_mainarea_add_file_table'></table>
</div> </div>
</div> </div>
<div id='file_show_mainarea_edit_file_form_div'> <div id='file_show_mainarea_edit_file_form'>
<table> <table>
<?php <?php
for ($i = 0; $i < $file_count; $i++) for ($i = 0; $i < $file_count; $i++)

View File

@ -23,6 +23,14 @@
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
<?php
$creole_base = site_url() . "/wiki/show/{$project->id}/";
// the issue page doesn't exist yet. so use wiki/attachment0 instead of
// issue/file/issueid. the local imange reference like {{xxx.png}}
// won't work. furthermore, the file hasn't been uploaded and isn't available.
$creole_file_base = site_url() . "/wiki/attachment0/{$project->id}/";
?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
function show_alert (outputMsg, titleMsg) function show_alert (outputMsg, titleMsg)
@ -53,13 +61,13 @@ function AsciiToHex (x) {
} }
function render_wiki(input_text) function preview_new_description(input_text)
{ {
creole_render_wiki_with_input_text ( creole_render_wiki_with_input_text (
input_text, input_text,
"issue_home_mainarea_new_description_preview", "issue_home_mainarea_new_description_preview",
"<?php print site_url()?>/issue/show/<?php print $project->id?>/", "<?php print $creole_base; ?>",
"<?php print site_url()?>/issue/file0/<?php print $project->id?>/" "<?php print $creole_file_base; ?>"
); );
prettyPrint (); prettyPrint ();
@ -121,9 +129,9 @@ $(function () {
populate_selected_files (); populate_selected_files ();
}); });
$("#issue_home_mainarea_new_description_tabs").tabs (); $('#issue_home_mainarea_new_description_tabs').tabs ();
$("#issue_home_mainarea_new_description_tabs").bind ('tabsshow', function (event, ui) { $('#issue_home_mainarea_new_description_tabs').bind ('tabsshow', function (event, ui) {
if (ui.index == 1) render_wiki ($("#issue_home_mainarea_new_description").val()); if (ui.index == 1) preview_new_description ($('#issue_home_mainarea_new_description').val());
}); });
$('#issue_home_mainarea_new_form').dialog ( $('#issue_home_mainarea_new_form').dialog (

View File

@ -24,6 +24,9 @@
<?php <?php
$hex_issue_id = $this->converter->AsciiToHex ($issue->id); $hex_issue_id = $this->converter->AsciiToHex ($issue->id);
$issue_file_count = count ($issue->files); $issue_file_count = count ($issue->files);
$creole_base = site_url() . "/wiki/show/{$project->id}/";
$creole_file_base = site_url() . "/issue/file/{$project->id}/{$issue->id}/";
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -165,7 +168,19 @@ function kill_edit_file (no)
d.prop ('disabled', true); d.prop ('disabled', true);
} }
} }
}
function preview_edit_description (input_text)
{
creole_render_wiki_with_input_text (
input_text,
"issue_show_mainarea_edit_description_preview",
"<?php print $creole_base; ?>",
"<?php print $creole_file_base; ?>/"
);
prettyPrint ();
} }
var work_in_progress = false; var work_in_progress = false;
@ -194,9 +209,9 @@ var original_file_desc = [
$(function () { $(function () {
<?php if (isset($login['id']) && $login['id'] != ''): ?> <?php if (isset($login['id']) && $login['id'] != ''): ?>
$("#issue_show_mainarea_edit_description_tabs").tabs (); $('#issue_show_mainarea_edit_description_tabs').tabs ();
$("#issue_show_mainarea_edit_description_tabs").bind ('tabsshow', function (event, ui) { $('#issue_show_mainarea_edit_description_tabs').bind ('tabsshow', function (event, ui) {
if (ui.index == 1) render_wiki ($("#issue_show_mainarea_edit_description").val()); if (ui.index == 1) preview_edit_description ($('#issue_show_mainarea_edit_description').val());
}); });
$('#issue_show_mainarea_edit_form').dialog ( $('#issue_show_mainarea_edit_form').dialog (
@ -608,14 +623,14 @@ $(function () {
); );
<?php endif; ?> <?php endif; ?>
$("#issue_show_mainarea_change_form_open").button().click ( $('#issue_show_mainarea_change_form_open').button().click (
function () { function () {
$('#issue_show_mainarea_change_form').dialog('open'); $('#issue_show_mainarea_change_form').dialog('open');
return false; return false;
} }
); );
$("#issue_show_mainarea_undo_change_confirm").dialog ( $('#issue_show_mainarea_undo_change_confirm').dialog (
{ {
title: '<?php print $this->lang->line('Undo')?>', title: '<?php print $this->lang->line('Undo')?>',
resizable: false, resizable: false,
@ -635,17 +650,17 @@ $(function () {
} }
); );
$("#issue_show_mainarea_undo_change").button().click ( $('#issue_show_mainarea_undo_change').button().click (
function () { function () {
$('#issue_show_mainarea_undo_change_confirm').dialog('open'); $('#issue_show_mainarea_undo_change_confirm').dialog('open');
return false; return false;
} }
); );
$('#issue_change_comment_preview_button').button().click(
$("#issue_change_comment_preview_button").button().click(
function () { function () {
render_wiki_comment_preview ($("#issue_change_comment").val()); preview_issue_change_comment ($('#issue_change_comment').val());
return false;
} }
); );
@ -925,7 +940,7 @@ $this->load->view (
'id="issue_show_mainarea_edit_type" disabled="disabled"' 'id="issue_show_mainarea_edit_type" disabled="disabled"'
); );
?> ?>
<input type='text' id='issue_show_mainarea_edit_summary' name='issue_home_new_summary' size='50' placeholder='<?php print $this->lang->line('Summary'); ?>' value='<?php print addslashes($issue->summary); ?>'/> <input type='text' id='issue_show_mainarea_edit_summary' name='issue_show_edit_summary' size='50' placeholder='<?php print $this->lang->line('Summary'); ?>' value='<?php print addslashes($issue->summary); ?>'/>
</div> </div>
<div id='issue_show_mainarea_edit_description_tabs' style='width:100%;'> <div id='issue_show_mainarea_edit_description_tabs' style='width:100%;'>
@ -935,7 +950,7 @@ $this->load->view (
</ul> </ul>
<div id='issue_show_mainarea_edit_description_input'> <div id='issue_show_mainarea_edit_description_input'>
<textarea type='textarea' id='issue_show_mainarea_edit_description' name='issue_home_new_description' rows=24 cols=100 style='width:100%;'><?php print htmlspecialchars($issue->description); ?></textarea> <textarea type='textarea' id='issue_show_mainarea_edit_description' name='issue_show_edit_description' rows=24 cols=100 style='width:100%;'><?php print htmlspecialchars($issue->description); ?></textarea>
</div> </div>
<div id='issue_show_mainarea_edit_description_preview' class='form_input_preview'> <div id='issue_show_mainarea_edit_description_preview' class='form_input_preview'>
</div> </div>
@ -1075,10 +1090,6 @@ $this->load->view (
<!----------------------------------------------------------------------------> <!---------------------------------------------------------------------------->
<?php
$creole_base = site_url() . "/issue/show/{$project->id}/{$issue->id}/";
$creole_attachment_base = site_url() . "/issue/file/{$project->id}/{$issue->id}/";
?>
<script type="text/javascript"> <script type="text/javascript">
function render_wiki() function render_wiki()
@ -1087,7 +1098,7 @@ function render_wiki()
"issue_show_mainarea_description_pre", "issue_show_mainarea_description_pre",
"issue_show_mainarea_description", "issue_show_mainarea_description",
"<?php print $creole_base?>", "<?php print $creole_base?>",
"<?php print $creole_attachment_base?>" "<?php print $creole_file_base?>"
); );
<?php <?php
@ -1099,7 +1110,7 @@ function render_wiki()
'issue_show_mainarea_changes_comment_pre_{$xxx}', 'issue_show_mainarea_changes_comment_pre_{$xxx}',
'issue_show_mainarea_changes_comment_{$xxx}', 'issue_show_mainarea_changes_comment_{$xxx}',
'{$creole_base}', '{$creole_base}',
'{$creole_attachment_base}');"; '{$creole_file_base}');";
} }
} }
?> ?>
@ -1107,13 +1118,13 @@ function render_wiki()
prettyPrint (); prettyPrint ();
} }
function render_wiki_comment_preview(input_text) function preview_issue_change_comment(input_text)
{ {
creole_render_wiki_with_input_text ( creole_render_wiki_with_input_text (
input_text, input_text,
"issue_change_comment_preview", "issue_change_comment_preview",
"<?php print $creole_base?>", "<?php print $creole_base?>",
"<?php print $creole_attachment_base?>" "<?php print $creole_file_base?>"
); );
prettyPrint (); prettyPrint ();

View File

@ -90,3 +90,32 @@
} }
/*-----------------------------------------------
* file home show - edit file dialog
*-----------------------------------------------*/
#file_show_mainarea_edit_description_tabs {
border: none !important;
}
#file_show_mainarea_edit_description_tabs .ui-tabs-panel {
padding: 0.2em 0em 0em 0em !important;
}
#file_show_mainarea_edit_description_tabs .ui-widget-header {
border: none !important;
background: none !important;
padding: 0em !important;
}
#file_show_mainarea_edit_description_tabs .ui-tabs-nav {
padding: 0em !important;
}
/* #file_show_mainarea_edit_description_tabs .ui-tabs-nav li { */
.ui-tabs .ui-tabs-nav li.ui-state-default {
border-bottom: 1px solid #cccccc !important;
}
.ui-tabs .ui-tabs-nav li.ui-state-active {
border-bottom: 1px solid #fbd850 !important;
}