changed the code revision view to use xhr calls.

added preview tab to review comment dialogs in the code revision view
This commit is contained in:
hyung-hwan 2016-01-07 15:48:46 +00:00
parent 93f7486dfb
commit 530e38ceb5
8 changed files with 802 additions and 317 deletions

View File

@ -245,7 +245,7 @@ class Code extends Controller
}
}
protected function _edit ($projectid = '', $path = '', $rev = SVN_REVISION_HEAD, $caller = 'file')
private function _edit ($projectid = '', $path = '', $rev = SVN_REVISION_HEAD, $caller = 'file')
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('SubversionModel', 'subversion');
@ -601,6 +601,266 @@ class Code extends Controller
print $status;
}
function xhr_edit_revision_message ($projectid = '', $rev = SVN_REVISOIN_HEAD)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('SubversionModel', 'subversion');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$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 if ($login['id'] != $this->subversion->getRevProp($projectid, $rev, 'svn:author'))
{
$status = "error - not authored by {$login['id']}";
}
else
{
$logmsg = $this->input->post('code_edit_revision_message');
if ($logmsg != $this->subversion->getRevProp ($projectid, $rev, 'svn:log'))
{
$affected_rev = $this->subversion->setRevProp (
$projectid, $rev, 'svn:log', $logmsg, $login['id']);
if ($affected_rev === FALSE)
{
$status = 'error - ' . $this->subversion->getErrorMessage();
}
else
{
$status = 'ok';
}
}
else
{
$status = 'ok';
}
}
}
print $status;
}
function xhr_edit_revision_tag ($projectid = '', $rev = SVN_REVISOIN_HEAD)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('SubversionModel', 'subversion');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$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 if ($login['id'] != $this->subversion->getRevProp($projectid, $rev, 'svn:author'))
//{
// $status = "error - not authored by {$login['id']}";
//}
else
{
$tag = $this->input->post('code_edit_revision_tag');
$tag = ($tag === FALSE)? '': trim($tag);
if (empty($tag))
{
// delete the tag if the value is empty
$affected_rev = $this->subversion->killRevProp (
$projectid, $rev, CODEPOT_SVN_TAG_PROPERTY, $login['id']);
}
else
{
$affected_rev = $this->subversion->setRevProp (
$projectid, $rev, CODEPOT_SVN_TAG_PROPERTY, $tag, $login['id']);
}
if ($affected_rev === FALSE)
{
$status = 'error - ' . $this->subversion->getErrorMessage();
}
else
{
$status = 'ok';
}
}
}
print $status;
}
function xhr_new_review_comment ($projectid = '', $rev = SVN_REVISOIN_HEAD)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('SubversionModel', 'subversion');
$this->load->model ('CodeReviewModel', 'code_review');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$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
{
$review_comment = $this->input->post('code_new_review_comment');
if ($review_comment === FALSE || ($review_comment = trim($review_comment)) == '')
{
$status = 'error - emtpy review comment';
}
else
{
$review_sno = $this->code_review->insertReview ($projectid, $rev, $login['id'], $review_comment);
if ($review_sno === FALSE)
{
$status = 'error - ' . $this->code_review->getErrorMessage();
}
else
{
$status = 'ok';
if (CODEPOT_COMMIT_REVIEW_NOTIFICATION)
{
// TODO: message localization
$email_subject = sprintf (
'New review message #%d for r%d by %s in %s',
$review_sno, $rev, $login['id'], $projectid
);
$email_message = current_url() . "\r\n" . $review_comment;
$this->projects->emailMessageToMembers (
$projectid, $this->login, $email_subject, $email_message
);
}
}
}
}
}
print $status;
}
function xhr_edit_review_comment ($projectid = '', $rev = SVN_REVISOIN_HEAD)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('SubversionModel', 'subversion');
$this->load->model ('CodeReviewModel', 'code_review');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$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
{
$review_no = $this->input->post('code_edit_review_no');
$review_comment = $this->input->post('code_edit_review_comment');
if ($review_no === FALSE || !is_numeric($review_no))
{
$status = 'error - wrong review number';
}
else if ($review_comment === FALSE || ($review_comment = trim($review_comment)) == '')
{
$status = 'error - empty review comment';
}
else
{
if ($this->code_review->updateReview ($projectid, $rev, (integer)$review_no, $login['id'], $review_comment, TRUE) === FALSE)
{
$status = 'error - ' . $this->code_review->getErrorMessage();
}
else
{
$status = 'ok';
/*
if (CODEPOT_COMMIT_REVIEW_NOTIFICATION)
{
// TODO: message localization
$email_subject = sprintf (
'Edited review message #%d for r%d by %s in %s',
$review_sno, $rev, $login['id'], $projectid
);
$email_message = current_url() . "\r\n" . $review_comment;
$this->projects->emailMessageToMembers (
$projectid, $this->login, $email_subject, $email_message
);
}*/
}
}
}
}
print $status;
}
function enjson_save ($projectid = '', $path = '')
{
$this->load->model ('ProjectModel', 'projects');
@ -771,147 +1031,6 @@ class Code extends Controller
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
}
$data['popup_error_message'] = '';
if ($login['id'] != '')
{
$tag = $this->input->post('tag_revision');
if ($tag !== FALSE)
{
$tag = trim($tag);
if (empty($tag))
{
// delete the tag if the value is empty
$affected_rev = $this->subversion->killRevProp (
$projectid, $rev, CODEPOT_SVN_TAG_PROPERTY, $login['id']);
}
else
{
$affected_rev = $this->subversion->setRevProp (
$projectid, $rev, CODEPOT_SVN_TAG_PROPERTY, $tag, $login['id']);
}
if ($affected_rev === FALSE)
{
$data['popup_error_message'] = 'Cannot tag revision';
}
else
{
$this->form_validation->_field_data = array();
}
}
else if ($login['id'] == $this->subversion->getRevProp($projectid, $rev, 'svn:author') &&
$this->input->post('edit_log_message'))
{
// the current user must be the author of the revision to be able to
// change the log message.
$this->load->helper ('form');
$this->load->library ('form_validation');
$this->form_validation->set_rules ('edit_log_message', 'Message', 'required|min_length[2]');
$this->form_validation->set_error_delimiters('<span class="form_field_error">','</span>');
if ($this->form_validation->run())
{
$logmsg = $this->input->post('edit_log_message');
if ($logmsg != $this->subversion->getRevProp ($projectid, $rev, 'svn:log'))
{
$affected_rev = $this->subversion->setRevProp (
$projectid, $rev, 'svn:log', $logmsg, $login['id']);
if ($affected_rev === FALSE)
{
$data['popup_error_message'] = 'Cannot change revision log message';
}
else
{
$this->form_validation->_field_data = array();
}
}
}
else
{
$data['popup_error_message'] = 'Invalid revision log message';
}
}
else if ($this->input->post('new_review_comment'))
{
$this->load->helper ('form');
$this->load->library ('form_validation');
$this->form_validation->set_rules ('new_review_comment', $this->lang->line('Comment'), 'required|min_length[10]');
$this->form_validation->set_error_delimiters('<span class="form_field_error">','</span>');
if ($this->form_validation->run())
{
$review_comment = $this->input->post('new_review_comment');
$review_sno = $this->code_review->insertReview ($projectid, $rev, $login['id'], $review_comment);
if ($review_sno === FALSE)
{
$data['popup_error_message'] = 'Cannot add code review comment';
}
else
{
// this is a hack to clear form data upon success
$this->form_validation->_field_data = array();
if (CODEPOT_COMMIT_REVIEW_NOTIFICATION)
{
// TODO: message localization
$email_subject = sprintf (
'New review message #%d for r%d by %s in %s',
$review_sno, $rev, $login['id'], $projectid
);
$email_message = current_url() . "\r\n" . $review_comment;
$this->projects->emailMessageToMembers (
$projectid, $this->login, $email_subject, $email_message
);
}
}
}
else
{
$data['popup_error_message'] = 'Invalid review comment';
}
}
else if ($this->input->post('edit_review_comment_no'))
{
$this->load->helper ('form');
$this->load->library ('form_validation');
// get the comment number without validation.
$comment_no = $this->input->post('edit_review_comment_no');
if (is_numeric($comment_no))
{
$comment_field_name = "edit_review_comment_{$comment_no}";
$this->form_validation->set_rules ($comment_field_name, $this->lang->line('Comment'), 'required|min_length[10]');
$this->form_validation->set_error_delimiters('<span class="form_field_error">','</span>');
if ($this->form_validation->run())
{
//
// TODO: should let sysadmin? to change comments???
//
$review_comment = $this->input->post($comment_field_name);
if ($this->code_review->updateReview ($projectid, $rev, (integer)$comment_no, $login['id'], $review_comment, TRUE) === FALSE)
{
$data['popup_error_message'] = 'Cannot edit code review comment';
}
else
{
// this is a hack to clear form data upon success
$this->form_validation->_field_data = array();
}
}
else
{
$data['popup_error_message'] = 'Invalid review comment';
}
}
else
{
$data['popup_error_message'] = 'Invalid review comment number';
}
}
}
$file = $this->subversion->getRevHistory ($projectid, $path, $rev);
if ($file === FALSE)
{
@ -1016,7 +1135,7 @@ class Code extends Controller
}
}
function _do_diff ($projectid = '', $path = '', $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_HEAD, $full = FALSE)
private function _do_diff ($projectid = '', $path = '', $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_HEAD, $full = FALSE)
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('SubversionModel', 'subversion');
@ -1208,7 +1327,7 @@ class Code extends Controller
}
}
function _search_code ($project, $login)
private function _search_code ($project, $login)
{
$this->load->helper ('form');
$this->load->library ('form_validation');
@ -1306,7 +1425,7 @@ class Code extends Controller
}
}
function _normalize_path ($path)
private function _normalize_path ($path)
{
$path = preg_replace('/[\/]+/', '/', $path);
if ($path == '/') $path = '';

View File

@ -2,6 +2,13 @@
class CodeReviewModel extends Model
{
protected $errmsg = '';
function getErrorMessage ()
{
return $this->errmsg;
}
function CodeReviewModel ()
{
parent::Model ();
@ -10,28 +17,27 @@ class CodeReviewModel extends Model
function getReviews ($projectid, $revision)
{
$this->db->trans_start ();
$this->db->trans_begin ();
$this->db->where ('projectid', (string)$projectid);
$this->db->where ('rev', $revision);
$query = $this->db->get ('code_review');
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_complete ();
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
$result = $query->result ();
$this->db->trans_complete ();
if ($this->db->trans_status() === FALSE) return FALSE;
$this->db->trans_commit ();
return $result;
}
function insertReview ($projectid, $revision, $userid, $comment)
{
// TODO: check if userid can do this..
$this->db->trans_start ();
$this->db->trans_begin ();
$this->db->where ('projectid', $projectid);
$this->db->where ('rev', $revision);
@ -39,7 +45,8 @@ class CodeReviewModel extends Model
$query = $this->db->get ('code_review');
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_complete ();
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
@ -57,25 +64,34 @@ class CodeReviewModel extends Model
$this->db->set ('createdby', $userid);
$this->db->set ('updatedby', $userid);
$this->db->insert ('code_review');
/*$this->db->set ('createdon', date('Y-m-d H:i:s'));
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', 'code_review');
$this->db->set ('action', 'insert');
$this->db->set ('projectid', $projectid);
$this->db->set ('userid', $userid);
$this->db->set ('message', "$rev,$sno");
$this->db->insert ('log');*/
$this->db->trans_complete ();
if ($this->db->trans_status() === FALSE) return FALSE;
$this->db->insert ('log');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}*/
$this->db->trans_commit ();
return $newsno;
}
function updateReview ($projectid, $revision, $sno, $userid, $comment, $strict = FALSE)
{
// TODO: check if userid can do this..
$this->db->trans_start ();
$this->db->trans_begin ();
$this->db->where ('projectid', $projectid);
$this->db->where ('rev', $revision);
@ -85,39 +101,63 @@ class CodeReviewModel extends Model
$this->db->set ('updatedon', date('Y-m-d H:i:s'));
$this->db->set ('updatedby', $userid);
$this->db->update ('code_review');
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 ('createdon', date('Y-m-d H:i:s'));
$this->db->set ('type', 'code_review');
$this->db->set ('action', 'insert');
$this->db->set ('projectid', $projectid);
$this->db->set ('userid', $userid);
$this->db->set ('message', "$rev,$sno");
$this->db->insert ('log');*/
$this->db->insert ('log');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}*/
$this->db->trans_complete ();
return $this->db->trans_status();
$this->db->trans_commit ();
return TRUE;
}
function deleteReview ($projectid, $revision, $sno, $userid)
{
// TODO: check if userid can do this..
$this->db->trans_start ();
$this->db->trans_begin();
$this->db->where ('projectid', $projectid);
$this->db->where ('rev', $revision);
$this->db->where ('sno', $sno);
$this->db->delete ('code_review');
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 ('createdon', date('Y-m-d H:i:s'));
$this->db->set ('type', 'issue');
$this->db->set ('action', 'delete');
$this->db->set ('projectid', $projectid);
$this->db->set ('userid', $userid);
$this->db->set ('message', "$rev,$sno");
$this->db->insert ('log');*/
$this->db->insert ('log');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
} */
$this->db->trans_complete ();
return $this->db->trans_status();
$this->db->trans_commit ();
return TRUE;
}
}

View File

@ -19,7 +19,7 @@ class SubversionModel extends Model
parent::Model ();
}
function _canonical_path($path)
private function _canonical_path($path)
{
$canonical = preg_replace('|/\.?(?=/)|','',$path);
while (($collapsed = preg_replace('|/[^/]+/\.\./|','/',$canonical,1)) !== $canonical)
@ -1231,19 +1231,26 @@ class SubversionModel extends Model
function getRevProp ($projectid, $rev, $prop)
{
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}");
return @svn_revprop_get ($url, $rev, $prop);
set_error_handler (array ($this, 'capture_error'));
$result = @svn_revprop_get ($url, $rev, $prop);
restore_error_handler ();
return $result;
}
function setRevProp ($projectid, $rev, $prop, $propval, $user)
{
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}");
set_error_handler (array ($this, 'capture_error'));
$orguser = @svn_auth_get_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME);
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $user);
$result = @svn_revprop_set ($url, $rev, $prop, $propval);
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $orguser);
restore_error_handler ();
return $result;
}
@ -1251,12 +1258,16 @@ class SubversionModel extends Model
{
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}");
set_error_handler (array ($this, 'capture_error'));
$orguser = @svn_auth_get_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME);
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $user);
$result = @svn_revprop_delete ($url, $rev, $prop);
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $orguser);
restore_error_handler ();
return $result;
}
@ -1315,7 +1326,9 @@ class SubversionModel extends Model
$orgurl = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$workurl = ($path == '')? $orgurl: "{$orgurl}@"; // trailing @ for collision prevention
set_error_handler (array ($this, 'capture_error'));
$info = @svn_info ($workurl, FALSE, $rev);
restore_error_handler ();
if ($info === FALSE || count($info) != 1)
{
@ -1323,11 +1336,16 @@ class SubversionModel extends Model
// rebuild the URL with a peg revision and retry it.
$workurl = "{$orgurl}@{$rev}";
set_error_handler (array ($this, 'capture_error'));
$info = @svn_info ($workurl, FALSE, $rev);
restore_error_handler ();
if ($info === FALSE || count($info) != 1) return FALSE;
}
return @svn_proplist ($workurl, 0, $rev);
set_error_handler (array ($this, 'capture_error'));
$result = @svn_proplist ($workurl, 0, $rev);
restore_error_handler ();
return $result;
}
function getProp ($projectid, $path, $rev, $prop)
@ -1335,7 +1353,9 @@ class SubversionModel extends Model
$orgurl = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$workurl = ($path == '')? $orgurl: "{$orgurl}@"; // trailing @ for collision prevention
set_error_handler (array ($this, 'capture_error'));
$info = @svn_info ($workurl, FALSE, $rev);
restore_error_handler ();
if ($info === FALSE || count($info) != 1)
{
@ -1343,11 +1363,16 @@ class SubversionModel extends Model
// rebuild the URL with a peg revision and retry it.
$workurl = "{$orgurl}@{$rev}";
set_error_handler (array ($this, 'capture_error'));
$info = @svn_info ($workurl, FALSE, $rev);
restore_error_handler ();
if ($info === FALSE || count($info) != 1) return FALSE;
}
return @svn_propget ($workurl, $prop, FALSE, $rev);
set_error_handler (array ($this, 'capture_error'));
$result = @svn_propget ($workurl, $prop, FALSE, $rev);
restore_error_handler ();
return $result;
}
function _cloc_revision_by_lang ($projectid, $path, $rev)

View File

@ -221,7 +221,8 @@ $this->load->view (
// anchor to the revision history at the root directory
print anchor (
"code/revision/{$project->id}/!/{$file['created_rev']}",
//"code/revision/{$project->id}/!/{$file['created_rev']}",
"code/revision/{$project->id}/${xpar}/{$file['created_rev']}",
sprintf("%s %s", $this->lang->line('Revision'), $file['created_rev'])
);

View File

@ -848,7 +848,8 @@ $this->load->view (
// anchor to the revision history at the root directory
print anchor (
"code/revision/{$project->id}/!/{$file['created_rev']}",
//"code/revision/{$project->id}/!/{$file['created_rev']}",
"code/revision/{$project->id}/${hex_headpath}/{$file['created_rev']}",
sprintf("%s %s", $this->lang->line('Revision'), $file['created_rev'])
);

View File

@ -21,6 +21,23 @@
<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')?>" />
<?php
if ($revision <= 0)
{
$revreq = '';
$revreqroot = '';
}
else
{
$revreq = "/{$file['created_rev']}";
$revreqroot = '/' . $this->converter->AsciiToHex ('.') . $revreq;
}
$hex_headpath = $this->converter->AsciiToHex(($headpath == '')? '.': $headpath);
$creole_base = site_url() . "/wiki/show/{$project->id}/";
$creole_file_base = site_url() . "/wiki/attachment0/{$project->id}/";
?>
<script type="text/javascript">
function show_alert (outputMsg, titleMsg)
@ -39,64 +56,202 @@ function show_alert (outputMsg, titleMsg)
});
}
function preview_new_review_comment (input_text)
{
creole_render_wiki_with_input_text (
input_text,
"code_revision_new_review_comment_preview",
"<?php print $creole_base; ?>",
"<?php print $creole_file_base; ?>/"
);
prettyPrint ();
}
function preview_edit_review_comment (input_text, no)
{
creole_render_wiki_with_input_text (
input_text,
"code_revision_edit_review_comment_preview_" + no,
"<?php print $creole_base; ?>",
"<?php print $creole_file_base; ?>/"
);
prettyPrint ();
}
var work_in_progress = false;
<?php $review_count = count($reviews); ?>
<?php $is_loggedin = ($login['id'] != ''); ?>
<?php $can_edit = ($is_loggedin && $login['id'] == $file['history']['author']); ?>
<?php if ($can_edit): ?>
$(function() {
$("#code_revision_tag_div").dialog (
$('#code_revision_edit_revision_tag_form').dialog (
{
title: '<?php print $this->lang->line('Tag')?>',
title: '<?php print $this->lang->line('Tag');?>',
resizable: true,
autoOpen: false,
width: 'auto',
height: 'auto',
resizable: false,
autoOpen: false,
modal: true,
buttons: {
'<?php print $this->lang->line('OK')?>': function () {
$('#code_revision_tag_form').submit ();
$(this).dialog('close');
if (work_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
work_in_progress = true;
var form_data = new FormData();
form_data.append ('code_edit_revision_tag', $('#code_revision_edit_revision_tag').val());
$('#code_revision_edit_revision_tag_form').dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/code/xhr_edit_revision_tag/{$project->id}/{$revreq}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
work_in_progress = false;
$('#code_revision_edit_revision_tag_form').dialog('enable');
$('#code_revision_edit_revision_tag_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 "/code/revision/{$project->id}/{$hex_headpath}{$revreq}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
work_in_progress = false;
$('#code_revision_edit_revision_tag_form').dialog('enable');
$('#code_revision_edit_revision_tag_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 () {
$(this).dialog('close');
if (work_in_progress) return;
$('#code_revision_edit_revision_tag_form').dialog('close');
}
},
close: function() { }
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !work_in_progress;
}
}
);
$("#code_revision_edit_div").dialog (
$('#code_revision_edit_revision_message_form').dialog (
{
title: '<?php print $this->lang->line('Edit')?>',
title: '<?php print $this->lang->line('Message');?>',
resizable: true,
autoOpen: false,
width: 'auto',
height: 'auto',
resizable: false,
autoOpen: false,
modal: true,
buttons: {
'<?php print $this->lang->line('OK')?>': function () {
$('#code_revision_edit_logmsg_form').submit ();
$(this).dialog('close');
if (work_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
work_in_progress = true;
var form_data = new FormData();
form_data.append ('code_edit_revision_message', $('#code_revision_edit_revision_message').val());
$('#code_revision_edit_revision_message_form').dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/code/xhr_edit_revision_message/{$project->id}/{$revreq}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
work_in_progress = false;
$('#code_revision_edit_revision_message_form').dialog('enable');
$('#code_revision_edit_revision_message_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 "/code/revision/{$project->id}/{$hex_headpath}{$revreq}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
work_in_progress = false;
$('#code_revision_edit_revision_message_form').dialog('enable');
$('#code_revision_edit_revision_message_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 () {
$(this).dialog('close');
if (work_in_progress) return;
$('#code_revision_edit_revision_message_form').dialog('close');
}
},
close: function() { }
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !work_in_progress;
}
}
);
$("#code_revision_tag_button").button().click (
$('#code_revision_edit_revision_tag_button').button().click (
function () {
$("#code_revision_tag_div").dialog('open');
$('#code_revision_edit_revision_tag_form').dialog('open');
return false;
}
);
$("#code_revision_edit_logmsg_button").button().click (
$('#code_revision_edit_revision_message_button').button().click (
function () {
$("#code_revision_edit_div").dialog('open');
$('#code_revision_edit_revision_message_form').dialog('open');
return false;
}
);
@ -105,34 +260,157 @@ $(function() {
<?php if ($is_loggedin): ?>
$(function() {
$("#code_revision_new_review_comment_div").dialog (
$('#code_revision_new_review_comment_tabs').tabs ();
$('#code_revision_new_review_comment_tabs').bind ('tabsshow', function (event, ui) {
if (ui.index == 1) preview_new_review_comment ($('#code_revision_new_review_comment').val());
});
$('#code_revision_new_review_comment_form').dialog (
{
title: '<?php print $this->lang->line('Comment')?>',
title: '<?php print $this->lang->line('Comment');?>',
resizable: true,
autoOpen: false,
width: 'auto',
height: 'auto',
resizable: false,
autoOpen: false,
modal: true,
buttons: {
'<?php print $this->lang->line('OK')?>': function () {
$('#code_revision_new_review_comment_form').submit ();
$(this).dialog('close');
if (work_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
work_in_progress = true;
var form_data = new FormData();
form_data.append ('code_new_review_comment', $('#code_revision_new_review_comment').val());
$('#code_revision_new_review_comment_form').dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/code/xhr_new_review_comment/{$project->id}/{$revreq}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
work_in_progress = false;
$('#code_revision_new_review_comment_form').dialog('enable');
$('#code_revision_new_review_comment_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 "/code/revision/{$project->id}/{$hex_headpath}{$revreq}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
work_in_progress = false;
$('#code_revision_new_review_comment_form').dialog('enable');
$('#code_revision_new_review_comment_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 () {
$(this).dialog('close');
if (work_in_progress) return;
$('#code_revision_new_review_comment_form').dialog('close');
}
},
close: function() { }
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !work_in_progress;
}
}
);
$("#code_revision_new_review_comment_button").button().click (
function () {
$("#code_revision_new_review_comment_div").dialog('open');
$('#code_revision_new_review_comment_form').dialog('open');
return false;
}
);
function make_edit_review_comment_ok_function (no)
{
var form_name = '#code_revision_edit_review_comment_form_' + no;
return function () {
if (work_in_progress) return;
if (!!window.FormData)
{
// FormData is supported
work_in_progress = true;
var form_data = new FormData();
form_data.append ('code_edit_review_no', no);
form_data.append ('code_edit_review_comment', $('#code_revision_edit_review_comment_' + no).val());
$(form_name).dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/code/xhr_edit_review_comment/{$project->id}/{$revreq}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
work_in_progress = false;
$(form_name).dialog('enable');
$(form_name).dialog('close');
if (data == 'ok')
{
// refresh the page
$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/code/revision/{$project->id}/{$hex_headpath}{$revreq}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
work_in_progress = false;
$(form_name).dialog('enable');
$(form_name).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
for ($i = 0; $i < $review_count; )
{
@ -144,8 +422,12 @@ $(function() {
$label_ok = $this->lang->line('OK');
$label_cancel = $this->lang->line('Cancel');
print ("
$('#code_revision_edit_review_comment_tabs_{$i}').tabs ();
$('#code_revision_edit_review_comment_tabs_{$i}').bind ('tabsshow', function (event, ui) {
if (ui.index == 1) preview_edit_review_comment ($('#code_revision_edit_review_comment_{$i}').val(), {$i});
});
$('#code_revision_edit_review_comment_div_{$i}').dialog (
$('#code_revision_edit_review_comment_form_{$i}').dialog (
{
title: '{$edit_title}',
width: 'auto',
@ -154,23 +436,22 @@ $(function() {
autoOpen: false,
modal: true,
buttons: {
'{$label_ok}': function () {
// dynamically add a comment number to edit
var hidden_comment_no = $('<input>').attr('type', 'hidden').attr('name', 'edit_review_comment_no').val('{$i}');
$('#code_revision_edit_review_comment_form_{$i}').append(hidden_comment_no).submit ();
$(this).dialog('close');
},
'{$label_ok}': make_edit_review_comment_ok_function ({$i}),
'{$label_cancel}': function () {
$(this).dialog('close');
if (work_in_progress) return;
$('#code_revision_edit_review_comment_form_{$i}').dialog('close');
}
},
close: function() { }
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !work_in_progress;
}
}
);
$('#code_revision_edit_review_comment_button_{$i}').button().click (
function () {
$('#code_revision_edit_review_comment_div_{$i}').dialog('open');
$('#code_revision_edit_review_comment_form_{$i}').dialog('open');
return false;
}
)
@ -190,8 +471,8 @@ function render_wiki()
creole_render_wiki (
"code_revision_mainarea_review_comment_text_" + (i + 1) ,
"code_revision_mainarea_review_comment_" + (i + 1),
"<?php print site_url()?>/wiki/show/<?php print $project->id?>/",
""
"<?php print $creole_base; ?>",
"<?php print $creole_file_base; ?>/"
);
<?php
@ -227,10 +508,6 @@ $(function() {
hide_unneeded_divs ();
render_wiki ();
<?php if (strlen($popup_error_message) > 0): ?>
show_alert (<?php print codepot_json_encode('<pre>' . htmlspecialchars($popup_error_message) . '</pre>'); ?>, "<?php print $this->lang->line('Error')?>");
<?php endif; ?>
});
</script>
@ -280,17 +557,6 @@ $history = $file['history'];
<div class="title" id="code_revision_mainarea_title">
<?php
if ($revision <= 0)
{
$revreq = '';
$revreqroot = '';
}
else
{
$revreq = "/{$file['created_rev']}";
$revreqroot = '/' . $this->converter->AsciiToHex ('.') . $revreq;
}
print anchor (
"code/revision/{$project->id}{$revreqroot}",
htmlspecialchars($project->name));
@ -330,29 +596,28 @@ $history = $file['history'];
<?php
$history_anchor_text = '<i class="fa fa-history"></i> ' . $this->lang->line('History');
$xpar = $this->converter->AsciiToHex(($headpath == '')? '.': $headpath);
if ($revision > 0 && $revision < $next_revision)
{
print anchor ("code/revision/{$project->id}/{$xpar}", $this->lang->line('Head revision'));
print anchor ("code/revision/{$project->id}/{$hex_headpath}", $this->lang->line('Head revision'));
print ' | ';
}
if ($revision > 0)
{
if ($xpar == '') $revtrailer = $revreqroot;
else $revtrailer = "/{$xpar}{$revreq}";
if ($hex_headpath == '') $revtrailer = $revreqroot;
else $revtrailer = "/{$hex_headpath}{$revreq}";
print anchor ("code/history/{$project->id}{$revtrailer}", $history_anchor_text);
}
else
{
print anchor ("code/history/{$project->id}/{$xpar}", $history_anchor_text);
print anchor ("code/history/{$project->id}/{$hex_headpath}", $history_anchor_text);
}
?>
</div> <!-- code_revision_mainarea_menu -->
<div class="infostrip" id="code_revision_mainarea_infostrip">
<?php
print anchor ("code/revision/{$project->id}/${xpar}/{$prev_revision}", '<i class="fa fa-arrow-circle-left"></i>');
print anchor ("code/revision/{$project->id}/${hex_headpath}/{$prev_revision}", '<i class="fa fa-arrow-circle-left"></i>');
print ' ';
printf ('%s %s', $this->lang->line('Revision'), $history['rev']);
@ -365,13 +630,13 @@ $history = $file['history'];
}
print ' ';
print anchor ("code/revision/{$project->id}/${xpar}/{$next_revision}", '<i class="fa fa-arrow-circle-right"></i>');
print anchor ("code/revision/{$project->id}/${hex_headpath}/{$next_revision}", '<i class="fa fa-arrow-circle-right"></i>');
if ($can_edit)
{
print ' ';
print '<span class="anchor">';
print anchor ("#", $this->lang->line('Tag'), array ('id' => 'code_revision_tag_button'));
print anchor ("#", $this->lang->line('Tag'), array ('id' => 'code_revision_edit_revision_tag_button'));
print '</span>';
}
@ -391,7 +656,7 @@ $history = $file['history'];
<?php if ($can_edit): ?>
<span class='anchor'>
<?php print anchor ("#", $this->lang->line('Edit'),
array ('id' => 'code_revision_edit_logmsg_button'));
array ('id' => 'code_revision_edit_revision_message_button'));
?>
</span>
<?php endif; ?>
@ -555,13 +820,84 @@ $history = $file['history'];
print "</pre>\n";
print "</div>\n";
}
?>
</div> <!-- code_revision_mainarea_review_comment -->
</div> <!-- code_revision_mainarea_result_comments -->
</div> <!-- code_revision_mainarea_result -->
<?php if ($can_edit): ?>
<div id="code_revision_edit_revision_tag_form">
<?php print
form_input (
array ('name' => 'code_edit_revision_tag',
'value' => $history['tag'],
'id' => 'code_revision_edit_revision_tag')
)
?>
</div>
<div id='code_revision_edit_revision_message_form'>
<?php print
form_textarea (
array ('name' => 'code_edit_revision_message',
'value' => $history['msg'], 'rows'=> 10, 'cols' => 70,
'id' => 'code_revision_edit_revision_message')
)
?>
</div>
<?php endif; ?> <!-- $can_edit -->
<?php if ($is_loggedin): ?>
<div id="code_revision_new_review_comment_form">
<div id='code_revision_new_review_comment_tabs' style='width:100%;'>
<ul>
<li><a href='#code_revision_new_review_comment_input'><?php print $this->lang->line('Comment'); ?></a></li>
<li><a href='#code_revision_new_review_comment_preview'><?php print $this->lang->line('Preview'); ?></a></li>
</ul>
<div id='code_revision_new_review_comment_input'>
<textarea type='textarea' id='code_revision_new_review_comment' name='code_new_review_comment' rows=24 cols=100 style='width:100%;'></textarea>
</div>
<div id='code_revision_new_review_comment_preview' class='form_input_preview'>
</div>
</div>
</div>
<?php
$comment_label = $this->lang->line('Comment');
$preview_label = $this->lang->line('Preview');
for ($i = 0; $i < $review_count; )
{
$rc = $reviews[$i];
$i++;
if ($login['id'] == $rc->updatedby)
{
$text = htmlspecialchars ($rc->comment);
print "
<div id='code_revision_edit_review_comment_form_{$i}'>
<div id='code_revision_edit_review_comment_tabs_{$i}' class='code_revision_edit_review_comment_tabs' style='width:100%;'>
<ul>
<li><a href='#code_revision_edit_review_comment_input_{$i}'>{$comment_label}</a></li>
<li><a href='#code_revision_edit_review_comment_preview_{$i}'>{$preview_label}</a></li>
</ul>
<div id='code_revision_edit_review_comment_input_{$i}'>
<textarea type='textarea' id='code_revision_edit_review_comment_{$i}' name='code_edit_review_comment_{$i}' rows=24 cols=100 style='width:100%;'>{$text}</textarea>
</div>
<div id='code_revision_edit_review_comment_preview_{$i}' class='form_input_preview'>
</div>
</div>
</div>
";
}
}
?>
<?php endif; ?> <!-- $is_loggedin -->
<div id='code_revision_mainarea_alert'></div>
</div> <!-- code_revision_mainarea -->
@ -576,75 +912,6 @@ $history = $file['history'];
<!---------------------------------------------------------------------------->
<?php if ($can_edit): ?>
<div id="code_revision_tag_div">
<?php print form_open("code/revision/{$project->id}${revreqroot}", 'id="code_revision_tag_form"')?>
<?php print
form_input (
array ('name' => 'tag_revision',
'value' => $history['tag'],
'id' => 'code_revision_tag')
)
?>
<?php print form_close()?>
</div>
<div id="code_revision_edit_div">
<?php print form_open("code/revision/{$project->id}${revreqroot}", 'id="code_revision_edit_logmsg_form"')?>
<?php print
form_textarea (
array ('name' => 'edit_log_message',
'value' => $history['msg'], 'rows'=> 10, 'cols' => 70,
'id' => 'code_revision_edit_log_message')
)
?>
<?php print form_close()?>
</div>
<?php endif; ?> <!-- $can_edit -->
<?php if ($is_loggedin): ?>
<div id="code_revision_new_review_comment_div">
<?php
print form_open("code/revision/{$project->id}${revreqroot}", 'id="code_revision_new_review_comment_form"');
print form_error('new_review_comment');
print '<br />';
print form_textarea (
array ('name' => 'new_review_comment',
'value' => set_value('new_review_comment', ''),
'rows'=> 20, 'cols' => 90,
'id' => 'code_revision_new_review_comment')
);
print form_close();
for ($i = $review_count; $i > 0; $i--)
{
$rc = $reviews[$i - 1];
if ($login['id'] == $rc->updatedby)
{
print "<div id='code_revision_edit_review_comment_div_{$i}'>\n";
print form_open("code/revision/{$project->id}${revreqroot}", "id='code_revision_edit_review_comment_form_{$i}'");
print form_error("edit_review_comment_{$i}");
print '<br />';
print form_textarea (
array ('name' => "edit_review_comment_{$i}",
'value' => $rc->comment, 'rows'=> 20, 'cols' => 90,
'id' => "code_revision_edit_review_comment_{$i}")
);
print form_close();
print "</div>\n";
}
}
?>
</div>
<?php endif; ?> <!-- $is_loggedin -->
</body>
</html>

View File

@ -1088,8 +1088,6 @@ $this->load->view (
<!---------------------------------------------------------------------------->
<script type="text/javascript">
function render_wiki()
{

View File

@ -443,3 +443,37 @@
-webkit-border-radius: 3px;
border-radius: 3px;
}
/*-----------------------------------------------
* code revision - dialogs
*-----------------------------------------------*/
#code_revision_new_review_comment_tabs,
.code_revision_edit_review_comment_tabs {
border: none !important;
}
#code_revision_new_review_comment_tabs .ui-tabs-panel,
.code_revision_edit_review_comment_tabs .ui-tabs-panel {
padding: 0.2em 0em 0em 0em !important;
}
#code_revision_new_review_comment_tabs .ui-widget-header,
.code_revision_edit_review_comment_tabs .ui-widget-header {
border: none !important;
background: none !important;
padding: 0em !important;
}
#code_revision_new_review_comment_tabs .ui-tabs-nav,
.code_revision_edit_review_comment_tabs .ui-tabs-nav {
padding: 0em !important;
}
.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;
}