enhanced the code folder view to allow renaming
This commit is contained in:
parent
c5ba6ef358
commit
986812edd5
@ -107,7 +107,7 @@ class Code extends Controller
|
|||||||
|
|
||||||
if (count($import_files) > 0 && $this->subversion->importFiles ($projectid, $path, $login['id'], $post_new_message, $import_files, $this->upload) === FALSE)
|
if (count($import_files) > 0 && $this->subversion->importFiles ($projectid, $path, $login['id'], $post_new_message, $import_files, $this->upload) === FALSE)
|
||||||
{
|
{
|
||||||
$popup_error_message = $this->subversion->import_files_errmsg;
|
$popup_error_message = $this->subversion->getErrorMessage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ class Code extends Controller
|
|||||||
|
|
||||||
if (count($import_files) > 0 && $this->subversion->importFiles ($projectid, $path, $login['id'], $post_new_message, $import_files, $this->upload) === FALSE)
|
if (count($import_files) > 0 && $this->subversion->importFiles ($projectid, $path, $login['id'], $post_new_message, $import_files, $this->upload) === FALSE)
|
||||||
{
|
{
|
||||||
$status = 'repoerr - ' . $this->subversion->import_files_errmsg;
|
$status = 'repoerr - ' . $this->subversion->getErrorMessage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -471,7 +471,6 @@ class Code extends Controller
|
|||||||
{
|
{
|
||||||
$this->load->model ('ProjectModel', 'projects');
|
$this->load->model ('ProjectModel', 'projects');
|
||||||
$this->load->model ('SubversionModel', 'subversion');
|
$this->load->model ('SubversionModel', 'subversion');
|
||||||
$this->load->library ('upload');
|
|
||||||
|
|
||||||
$login = $this->login->getUser ();
|
$login = $this->login->getUser ();
|
||||||
$revision_saved = -1;
|
$revision_saved = -1;
|
||||||
@ -512,9 +511,72 @@ class Code extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($delete_files) > 0 && $this->subversion->deleteFiles ($projectid, $path, $login['id'], $post_delete_message, $delete_files, $this->upload) === FALSE)
|
if (count($delete_files) > 0 && $this->subversion->deleteFiles ($projectid, $path, $login['id'], $post_delete_message, $delete_files) === FALSE)
|
||||||
{
|
{
|
||||||
$status = 'repoerr - ' . $this->subversion->delete_files_errmsg;
|
$status = 'repoerr - ' . $this->subversion->getErrorMessage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$status = 'ok';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$status = 'posterr - invalid post data';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
function xhr_rename ($projectid = '', $path = '')
|
||||||
|
{
|
||||||
|
$this->load->model ('ProjectModel', 'projects');
|
||||||
|
$this->load->model ('SubversionModel', 'subversion');
|
||||||
|
|
||||||
|
$login = $this->login->getUser ();
|
||||||
|
$revision_saved = -1;
|
||||||
|
|
||||||
|
if ($login['id'] == '')
|
||||||
|
{
|
||||||
|
$status = 'signin';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$path = $this->converter->HexToAscii ($path);
|
||||||
|
if ($path == '.') $path = ''; /* treat a period specially */
|
||||||
|
$path = $this->_normalize_path ($path);
|
||||||
|
|
||||||
|
$project = $this->projects->get ($projectid);
|
||||||
|
if ($project === FALSE)
|
||||||
|
{
|
||||||
|
$status = "dberr - failed to get the project {$projectid}";
|
||||||
|
}
|
||||||
|
else if ($project === NULL)
|
||||||
|
{
|
||||||
|
$status = "noent - no such project {$projectid}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$post_rename_message = $this->input->post('code_rename_message');
|
||||||
|
$post_rename_file_count = $this->input->post('code_rename_file_count');
|
||||||
|
if ($post_rename_message !== FALSE && $post_rename_file_count !== FALSE)
|
||||||
|
{
|
||||||
|
$rename_files = array ();
|
||||||
|
for ($i = 0; $i < $post_rename_file_count; $i++)
|
||||||
|
{
|
||||||
|
$d1 = $this->input->post("code_rename_file_old_$i");
|
||||||
|
$d2 = $this->input->post("code_rename_file_new_$i");
|
||||||
|
if (strlen($d1) > 0 && strlen($d2) > 0)
|
||||||
|
{
|
||||||
|
array_push ($rename_files, array($d1, $d2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($rename_files) > 0 && $this->subversion->renameFiles ($projectid, $path, $login['id'], $post_rename_message, $rename_files) === FALSE)
|
||||||
|
{
|
||||||
|
$status = 'repoerr - ' . $this->subversion->getErrorMessage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -570,7 +632,7 @@ class Code extends Controller
|
|||||||
{
|
{
|
||||||
if ($this->subversion->storeFile ($projectid, $path, $login['id'], $message, $text) === FALSE)
|
if ($this->subversion->storeFile ($projectid, $path, $login['id'], $message, $text) === FALSE)
|
||||||
{
|
{
|
||||||
$status = 'repoerr - ' . $this->subversion->store_file_errmsg;
|
$status = 'repoerr - ' . $this->subversion->getErrorMessage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -16,4 +16,5 @@ $lang['CODE_SEARCH_IS_REGEX'] = 'Search string is a regular expression';
|
|||||||
$lang['CODE_SEARCH_WILDCARD'] = 'Enter a wildcard pattern';
|
$lang['CODE_SEARCH_WILDCARD'] = 'Enter a wildcard pattern';
|
||||||
|
|
||||||
$lang['CODE_FMT_DELETE_X_SELECTED_FILES'] = 'Delete %d selected file(s)';
|
$lang['CODE_FMT_DELETE_X_SELECTED_FILES'] = 'Delete %d selected file(s)';
|
||||||
|
$lang['CODE_FMT_RENAME_X_SELECTED_FILES'] = 'Rename %d selected file(s)';
|
||||||
?>
|
?>
|
||||||
|
@ -83,6 +83,7 @@ $lang['Projects'] = 'Projects';
|
|||||||
$lang['Public'] = 'Public';
|
$lang['Public'] = 'Public';
|
||||||
$lang['Purge'] = 'Purge';
|
$lang['Purge'] = 'Purge';
|
||||||
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
||||||
|
$lang['Rename'] = 'Rename';
|
||||||
$lang['Repository'] = 'Repository';
|
$lang['Repository'] = 'Repository';
|
||||||
$lang['Return'] = 'Return';
|
$lang['Return'] = 'Return';
|
||||||
$lang['Revision'] = 'Revision';
|
$lang['Revision'] = 'Revision';
|
||||||
|
@ -83,6 +83,7 @@ $lang['Projects'] = 'Proyek';
|
|||||||
$lang['Public'] = 'Public';
|
$lang['Public'] = 'Public';
|
||||||
$lang['Purge'] = 'Purge';
|
$lang['Purge'] = 'Purge';
|
||||||
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
||||||
|
$lang['Rename'] = 'Rename';
|
||||||
$lang['Return'] = 'Return';
|
$lang['Return'] = 'Return';
|
||||||
$lang['Repository'] = 'Repository';
|
$lang['Repository'] = 'Repository';
|
||||||
$lang['Revision'] = 'Revisi';
|
$lang['Revision'] = 'Revisi';
|
||||||
|
@ -16,5 +16,5 @@ $lang['CODE_SEARCH_IS_REGEX'] = '검색어가 정규식입니다';
|
|||||||
$lang['CODE_SEARCH_WILDCARD'] = '와일드카드 패턴을 입력하세요';
|
$lang['CODE_SEARCH_WILDCARD'] = '와일드카드 패턴을 입력하세요';
|
||||||
|
|
||||||
$lang['CODE_FMT_DELETE_X_SELECTED_FILES'] = '선택된 파일 %d개를 삭제합니다';
|
$lang['CODE_FMT_DELETE_X_SELECTED_FILES'] = '선택된 파일 %d개를 삭제합니다';
|
||||||
|
$lang['CODE_FMT_RENAME_X_SELECTED_FILES'] = '선택된 파일 %d개의 이름변경';
|
||||||
?>
|
?>
|
||||||
|
@ -83,6 +83,7 @@ $lang['Projects'] = '프로젝트';
|
|||||||
$lang['Public'] = '공개';
|
$lang['Public'] = '공개';
|
||||||
$lang['Purge'] = '정화하기';
|
$lang['Purge'] = '정화하기';
|
||||||
$lang['Recently resolved issues'] = '최근해결이슈';
|
$lang['Recently resolved issues'] = '최근해결이슈';
|
||||||
|
$lang['Rename'] = '이름변경';
|
||||||
$lang['Return'] = '복귀';
|
$lang['Return'] = '복귀';
|
||||||
$lang['Repository'] = '저장소';
|
$lang['Repository'] = '저장소';
|
||||||
$lang['Revision'] = '리비전';
|
$lang['Revision'] = '리비전';
|
||||||
|
@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
class SubversionModel extends Model
|
class SubversionModel extends Model
|
||||||
{
|
{
|
||||||
|
protected $errmsg = '';
|
||||||
|
|
||||||
|
function capture_error ($errno, $errmsg)
|
||||||
|
{
|
||||||
|
$this->errmsg = $errmsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getErrorMessage ()
|
||||||
|
{
|
||||||
|
return $this->errmsg;
|
||||||
|
}
|
||||||
|
|
||||||
function SubversionModel ()
|
function SubversionModel ()
|
||||||
{
|
{
|
||||||
parent::Model ();
|
parent::Model ();
|
||||||
@ -249,28 +261,10 @@ class SubversionModel extends Model
|
|||||||
return $fileinfo;
|
return $fileinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public $store_file_errmsg = '';
|
|
||||||
public $import_files_errmsg = '';
|
|
||||||
public $delete_files_errmsg = '';
|
|
||||||
|
|
||||||
function capture_save_error ($errno, $errmsg)
|
|
||||||
{
|
|
||||||
$this->store_file_errmsg = $errmsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
function capture_import_error ($errno, $errmsg)
|
|
||||||
{
|
|
||||||
$this->import_files_errmsg = $errmsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
function capture_delete_error ($errno, $errmsg)
|
|
||||||
{
|
|
||||||
$this->delete_files_errmsg = $errmsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
function storeFile ($projectid, $path, $committer, $commit_message, $text)
|
function storeFile ($projectid, $path, $committer, $commit_message, $text)
|
||||||
{
|
{
|
||||||
$store_file_errmsg = '';
|
$errmsg = '';
|
||||||
|
|
||||||
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
||||||
$canon_path = $this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
|
$canon_path = $this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
|
||||||
@ -278,7 +272,7 @@ class SubversionModel extends Model
|
|||||||
$file_name = basename($canon_path);
|
$file_name = basename($canon_path);
|
||||||
$dirurl = 'file://' . $canon_dir;
|
$dirurl = 'file://' . $canon_dir;
|
||||||
|
|
||||||
set_error_handler (array ($this, 'capture_save_error'));
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
$tfname = @tempnam(__FILE__, 'codepot-store-file-');
|
$tfname = @tempnam(__FILE__, 'codepot-store-file-');
|
||||||
restore_error_handler ();
|
restore_error_handler ();
|
||||||
if ($tfname === FALSE)
|
if ($tfname === FALSE)
|
||||||
@ -290,7 +284,7 @@ class SubversionModel extends Model
|
|||||||
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
||||||
|
|
||||||
/* TODO: optimize it not to get all files... svn_checkout needs to be enhanced???*/
|
/* TODO: optimize it not to get all files... svn_checkout needs to be enhanced???*/
|
||||||
set_error_handler (array ($this, 'capture_save_error'));
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
if (@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
if (@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
||||||
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, SVN_NON_RECURSIVE) === FALSE ||
|
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, SVN_NON_RECURSIVE) === FALSE ||
|
||||||
@file_put_contents ("{$actual_tfname}/{$file_name}", $text) === FALSE ||
|
@file_put_contents ("{$actual_tfname}/{$file_name}", $text) === FALSE ||
|
||||||
@ -310,7 +304,7 @@ class SubversionModel extends Model
|
|||||||
|
|
||||||
function importFiles ($projectid, $path, $committer, $commit_message, $files, $uploader)
|
function importFiles ($projectid, $path, $committer, $commit_message, $files, $uploader)
|
||||||
{
|
{
|
||||||
$this->import_files_errmsg = '';
|
$this->errmsg = '';
|
||||||
|
|
||||||
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
||||||
$full_path = CODEPOT_SVNREPO_DIR."/{$projectid}";
|
$full_path = CODEPOT_SVNREPO_DIR."/{$projectid}";
|
||||||
@ -318,7 +312,7 @@ class SubversionModel extends Model
|
|||||||
$canon_path = $this->_canonical_path($full_path);
|
$canon_path = $this->_canonical_path($full_path);
|
||||||
$dirurl = 'file://' . $canon_path;
|
$dirurl = 'file://' . $canon_path;
|
||||||
|
|
||||||
set_error_handler (array ($this, 'capture_import_error'));
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
$tfname = @tempnam(__FILE__, 'codepot-import-files-');
|
$tfname = @tempnam(__FILE__, 'codepot-import-files-');
|
||||||
restore_error_handler ();
|
restore_error_handler ();
|
||||||
if ($tfname === FALSE)
|
if ($tfname === FALSE)
|
||||||
@ -329,10 +323,9 @@ class SubversionModel extends Model
|
|||||||
$actual_tfname = $tfname . '.d';
|
$actual_tfname = $tfname . '.d';
|
||||||
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
||||||
|
|
||||||
mkdir ($actual_tfname);
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
|
if (@mkdir ($actual_tfname) === FALSE ||
|
||||||
set_error_handler (array ($this, 'capture_import_error'));
|
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
||||||
if (@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
|
||||||
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, 0) === FALSE)
|
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, 0) === FALSE)
|
||||||
{
|
{
|
||||||
restore_error_handler ();
|
restore_error_handler ();
|
||||||
@ -455,9 +448,9 @@ class SubversionModel extends Model
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFiles ($projectid, $path, $committer, $commit_message, $files, $uploader)
|
function deleteFiles ($projectid, $path, $committer, $commit_message, $files)
|
||||||
{
|
{
|
||||||
$this->delete_files_errmsg = '';
|
$this->errmsg = '';
|
||||||
|
|
||||||
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
||||||
$full_path = CODEPOT_SVNREPO_DIR."/{$projectid}";
|
$full_path = CODEPOT_SVNREPO_DIR."/{$projectid}";
|
||||||
@ -465,7 +458,7 @@ class SubversionModel extends Model
|
|||||||
$canon_path = $this->_canonical_path($full_path);
|
$canon_path = $this->_canonical_path($full_path);
|
||||||
$dirurl = 'file://' . $canon_path;
|
$dirurl = 'file://' . $canon_path;
|
||||||
|
|
||||||
set_error_handler (array ($this, 'capture_delete_error'));
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
$tfname = @tempnam(__FILE__, 'codepot-delete-files-');
|
$tfname = @tempnam(__FILE__, 'codepot-delete-files-');
|
||||||
restore_error_handler ();
|
restore_error_handler ();
|
||||||
if ($tfname === FALSE)
|
if ($tfname === FALSE)
|
||||||
@ -476,10 +469,9 @@ class SubversionModel extends Model
|
|||||||
$actual_tfname = $tfname . '.d';
|
$actual_tfname = $tfname . '.d';
|
||||||
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
||||||
|
|
||||||
mkdir ($actual_tfname);
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
|
if (@mkdir ($actual_tfname) === FALSE ||
|
||||||
set_error_handler (array ($this, 'capture_delete_error'));
|
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
||||||
if (@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
|
||||||
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, 0) === FALSE)
|
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, 0) === FALSE)
|
||||||
{
|
{
|
||||||
restore_error_handler ();
|
restore_error_handler ();
|
||||||
@ -515,6 +507,77 @@ class SubversionModel extends Model
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renameFiles ($projectid, $path, $committer, $commit_message, $files)
|
||||||
|
{
|
||||||
|
$this->errmsg = '';
|
||||||
|
|
||||||
|
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
||||||
|
$full_path = CODEPOT_SVNREPO_DIR."/{$projectid}";
|
||||||
|
if (strlen($path) > 0) $full_path .= "/{$path}";
|
||||||
|
$canon_path = $this->_canonical_path($full_path);
|
||||||
|
$dirurl = 'file://' . $canon_path;
|
||||||
|
|
||||||
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
|
$tfname = @tempnam(__FILE__, 'codepot-rename-files-');
|
||||||
|
restore_error_handler ();
|
||||||
|
if ($tfname === FALSE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$actual_tfname = $tfname . '.d';
|
||||||
|
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
||||||
|
|
||||||
|
set_error_handler (array ($this, 'capture_error'));
|
||||||
|
if (@mkdir ($actual_tfname) === FALSE ||
|
||||||
|
@svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $committer) === FALSE ||
|
||||||
|
@svn_checkout ($dirurl, $actual_tfname, SVN_REVISION_HEAD, 0) === FALSE)
|
||||||
|
{
|
||||||
|
restore_error_handler ();
|
||||||
|
codepot_delete_files ($actual_tfname, TRUE);
|
||||||
|
@unlink ($tfname);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($files as $f)
|
||||||
|
{
|
||||||
|
$xname = $actual_tfname . '/' . $f[0];
|
||||||
|
$yname = $actual_tfname . '/' . $f[1];
|
||||||
|
|
||||||
|
if ($f[0] == $f[1]) continue;
|
||||||
|
|
||||||
|
if (@file_exists($yname))
|
||||||
|
{
|
||||||
|
$this->errmsg = "{$f[1]} already exists";
|
||||||
|
restore_error_handler ();
|
||||||
|
codepot_delete_files ($actual_tfname, TRUE);
|
||||||
|
@unlink ($tfname);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@svn_move ($xname, $yname, TRUE) === FALSE)
|
||||||
|
{
|
||||||
|
restore_error_handler ();
|
||||||
|
codepot_delete_files ($actual_tfname, TRUE);
|
||||||
|
@unlink ($tfname);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($result = @svn_commit ($commit_message, $actual_tfname)) === FALSE)
|
||||||
|
{
|
||||||
|
restore_error_handler ();
|
||||||
|
codepot_delete_files ($actual_tfname, TRUE);
|
||||||
|
@unlink ($tfname);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_error_handler ();
|
||||||
|
codepot_delete_files ($actual_tfname, TRUE); // delete the directory in case it exists
|
||||||
|
@unlink ($tfname);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
function getRevHistory ($projectid, $path, $rev)
|
function getRevHistory ($projectid, $path, $rev)
|
||||||
{
|
{
|
||||||
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
||||||
|
@ -201,6 +201,8 @@ function render_readme()
|
|||||||
var new_item_no = 0;
|
var new_item_no = 0;
|
||||||
var import_in_progress = false;
|
var import_in_progress = false;
|
||||||
var delete_in_progress = false;
|
var delete_in_progress = false;
|
||||||
|
var rename_in_progress = false;
|
||||||
|
var rename_last_input = {};
|
||||||
|
|
||||||
function get_new_item_html(no, type, name)
|
function get_new_item_html(no, type, name)
|
||||||
{
|
{
|
||||||
@ -212,9 +214,9 @@ $(function () {
|
|||||||
<?php if (isset($login['id']) && $login['id'] != ''): ?>
|
<?php if (isset($login['id']) && $login['id'] != ''): ?>
|
||||||
|
|
||||||
new_item_no = 0;
|
new_item_no = 0;
|
||||||
$('#code_folder_mainarea_new_file_form_item_list').append (get_new_item_html(new_item_no, 'file', 'file'));
|
$('#code_folder_mainarea_new_file_list').append (get_new_item_html(new_item_no, 'file', 'file'));
|
||||||
$('#code_folder_mainarea_new_dir_form_item_list').append (get_new_item_html(new_item_no, 'text', 'dir'));
|
$('#code_folder_mainarea_new_dir_list').append (get_new_item_html(new_item_no, 'text', 'dir'));
|
||||||
$('#code_folder_mainarea_new_empfile_form_item_list').append (get_new_item_html(new_item_no, 'text', 'empfile'));
|
$('#code_folder_mainarea_new_empfile_list').append (get_new_item_html(new_item_no, 'text', 'empfile'));
|
||||||
|
|
||||||
$("#code_folder_mainarea_new_form_tabs").tabs ();
|
$("#code_folder_mainarea_new_form_tabs").tabs ();
|
||||||
|
|
||||||
@ -231,9 +233,9 @@ $(function () {
|
|||||||
if (import_in_progress) return;
|
if (import_in_progress) return;
|
||||||
|
|
||||||
++new_item_no;
|
++new_item_no;
|
||||||
$('#code_folder_mainarea_new_file_form_item_list').append (get_new_item_html(new_item_no, 'file', 'file'));
|
$('#code_folder_mainarea_new_file_list').append (get_new_item_html(new_item_no, 'file', 'file'));
|
||||||
$('#code_folder_mainarea_new_dir_form_item_list').append (get_new_item_html(new_item_no, 'text', 'dir'));
|
$('#code_folder_mainarea_new_dir_list').append (get_new_item_html(new_item_no, 'text', 'dir'));
|
||||||
$('#code_folder_mainarea_new_empfile_form_item_list').append (get_new_item_html(new_item_no, 'text', 'empfile'));
|
$('#code_folder_mainarea_new_empfile_list').append (get_new_item_html(new_item_no, 'text', 'empfile'));
|
||||||
},
|
},
|
||||||
'<?php print $this->lang->line('OK')?>': function () {
|
'<?php print $this->lang->line('OK')?>': function () {
|
||||||
if (import_in_progress) return;
|
if (import_in_progress) return;
|
||||||
@ -328,8 +330,6 @@ $(function () {
|
|||||||
'<?php print $this->lang->line('OK')?>': function () {
|
'<?php print $this->lang->line('OK')?>': function () {
|
||||||
if (delete_in_progress) return;
|
if (delete_in_progress) return;
|
||||||
|
|
||||||
$('#code_folder_mainarea_new_item_count').val (new_item_no + 1);
|
|
||||||
|
|
||||||
if (!!window.FormData)
|
if (!!window.FormData)
|
||||||
{
|
{
|
||||||
// FormData is supported
|
// FormData is supported
|
||||||
@ -339,7 +339,7 @@ $(function () {
|
|||||||
|
|
||||||
form_data.append ('code_delete_message', $('#code_folder_mainarea_delete_message').val());
|
form_data.append ('code_delete_message', $('#code_folder_mainarea_delete_message').val());
|
||||||
var xi = 0;
|
var xi = 0;
|
||||||
for (var i = 0; i < <?php print $file_count; ?>; i++)
|
for (var i = 1; i <= <?php print $file_count; ?>; i++)
|
||||||
{
|
{
|
||||||
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
||||||
if (f != null && f.is(':checked'))
|
if (f != null && f.is(':checked'))
|
||||||
@ -403,23 +403,152 @@ $(function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog (
|
||||||
|
{
|
||||||
|
title: '<?php print $this->lang->line('rename');?>',
|
||||||
|
resizable: true,
|
||||||
|
autoOpen: false,
|
||||||
|
width: 'auto',
|
||||||
|
height: 'auto',
|
||||||
|
modal: true,
|
||||||
|
buttons: {
|
||||||
|
'<?php print $this->lang->line('OK')?>': function () {
|
||||||
|
if (rename_in_progress) return;
|
||||||
|
|
||||||
|
if (!!window.FormData)
|
||||||
|
{
|
||||||
|
// FormData is supported
|
||||||
|
rename_in_progress = true;
|
||||||
|
|
||||||
|
var form_data = new FormData();
|
||||||
|
|
||||||
|
form_data.append ('code_rename_message', $('#code_folder_mainarea_rename_message').val());
|
||||||
|
var xi = 0;
|
||||||
|
for (var i = 1; i <= <?php print $file_count; ?>; i++)
|
||||||
|
{
|
||||||
|
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
||||||
|
if (f != null && f.is(':checked'))
|
||||||
|
{
|
||||||
|
form_data.append ('code_rename_file_old_' + xi, f.val());
|
||||||
|
|
||||||
|
var fx = $('#code_folder_mainarea_rename_file_' + xi);
|
||||||
|
var fxv = fx != null? fx.val(): '';
|
||||||
|
form_data.append ('code_rename_file_new_' + xi, fxv);
|
||||||
|
|
||||||
|
xi++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
form_data.append ('code_rename_file_count', xi);
|
||||||
|
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('disable');
|
||||||
|
$.ajax({
|
||||||
|
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/code/xhr_rename/{$project->id}/{$hex_headpath}"; ?>'),
|
||||||
|
type: 'POST',
|
||||||
|
data: form_data,
|
||||||
|
mimeType: 'multipart/form-data',
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
cache: false,
|
||||||
|
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
rename_in_progress = false;
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('enable');
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('close');
|
||||||
|
if (data == 'ok')
|
||||||
|
{
|
||||||
|
// refresh the page to the head revision
|
||||||
|
$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/code/file/{$project->id}/{$hex_headpath}"; ?>'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
rename_in_progress = false;
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('enable');
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('close');
|
||||||
|
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>");
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
'<?php print $this->lang->line('Cancel')?>': function () {
|
||||||
|
if (rename_in_progress) return;
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('close');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeClose: function() {
|
||||||
|
// if importing is in progress, prevent dialog closing
|
||||||
|
rename_last_input = {};
|
||||||
|
var xi = 0;
|
||||||
|
for (var i = 1; i <= <?php print $file_count; ?>; i++)
|
||||||
|
{
|
||||||
|
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
||||||
|
if (f != null && f.is(':checked'))
|
||||||
|
{
|
||||||
|
var fx = $('#code_folder_mainarea_rename_file_' + xi);
|
||||||
|
var fxv = fx != null? fx.val(): '';
|
||||||
|
rename_last_input[f.val()] = fxv;
|
||||||
|
|
||||||
|
xi++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !rename_in_progress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('#code_folder_mainarea_new_button').button().click (function() {
|
$('#code_folder_mainarea_new_button').button().click (function() {
|
||||||
$('#code_folder_mainarea_new_form_div').dialog('open');
|
$('#code_folder_mainarea_new_form_div').dialog('open');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#code_folder_mainarea_delete_button').button().click (function() {
|
$('#code_folder_mainarea_delete_button').button().click (function() {
|
||||||
var xi = 0;
|
var xi = 0;
|
||||||
for (var i = 0; i < <?php print $file_count; ?>; i++)
|
for (var i = 1; i <= <?php print $file_count; ?>; i++)
|
||||||
{
|
{
|
||||||
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
||||||
if (f != null && f.is(':checked')) xi++;
|
if (f != null && f.is(':checked')) xi++;
|
||||||
}
|
}
|
||||||
$('#code_folder_mainarea_delete_display_message').text (
|
$('#code_folder_mainarea_delete_form_div').dialog ('option', 'title',
|
||||||
codepot_sprintf ("<?php print addslashes($this->lang->line('CODE_FMT_DELETE_X_SELECTED_FILES')) ?>", xi)
|
codepot_sprintf ("<?php print addslashes($this->lang->line('CODE_FMT_DELETE_X_SELECTED_FILES')) ?>", xi)
|
||||||
);
|
);
|
||||||
$('#code_folder_mainarea_delete_form_div').dialog('open');
|
$('#code_folder_mainarea_delete_form_div').dialog('open');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#code_folder_mainarea_rename_button').button().click (function() {
|
||||||
|
var xi = 0;
|
||||||
|
|
||||||
|
$('#code_folder_mainarea_rename_file_table').empty();
|
||||||
|
for (var i = 1; i <= <?php print $file_count; ?>; i++)
|
||||||
|
{
|
||||||
|
var f = $('#code_folder_mainarea_result_table_file_selector_' + i);
|
||||||
|
if (f != null && f.is(':checked'))
|
||||||
|
{
|
||||||
|
var li = rename_last_input[f.val()];
|
||||||
|
if (li == null) li = '';
|
||||||
|
$('#code_folder_mainarea_rename_file_table').append (
|
||||||
|
codepot_sprintf ('<tr><td>%s</td><td><input type="text" id="code_folder_mainarea_rename_file_%d" value="%s"/></td></tr>',
|
||||||
|
codepot_htmlspecialchars(f.val()), xi, codepot_addslashes(li))
|
||||||
|
);
|
||||||
|
xi++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog ('option', 'title',
|
||||||
|
codepot_sprintf ("<?php print addslashes($this->lang->line('CODE_FMT_RENAME_X_SELECTED_FILES')) ?>", xi)
|
||||||
|
);
|
||||||
|
$('#code_folder_mainarea_rename_form_div').dialog('open');
|
||||||
|
});
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($file_count > 0): ?>
|
<?php if ($file_count > 0): ?>
|
||||||
@ -699,6 +828,7 @@ $this->load->view (
|
|||||||
{
|
{
|
||||||
printf ('<a id="code_folder_mainarea_new_button" href="#">%s</a>', $this->lang->line('New'));
|
printf ('<a id="code_folder_mainarea_new_button" href="#">%s</a>', $this->lang->line('New'));
|
||||||
printf ('<a id="code_folder_mainarea_delete_button" href="#">%s</a>', $this->lang->line('Delete'));
|
printf ('<a id="code_folder_mainarea_delete_button" href="#">%s</a>', $this->lang->line('Delete'));
|
||||||
|
printf ('<a id="code_folder_mainarea_rename_button" href="#">%s</a>', $this->lang->line('Rename'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($file_count > 0)
|
if ($file_count > 0)
|
||||||
@ -965,13 +1095,13 @@ $this->load->view (
|
|||||||
</ul>
|
</ul>
|
||||||
<div id="code_folder_mainarea_new_file_div">
|
<div id="code_folder_mainarea_new_file_div">
|
||||||
<div><input type='checkbox' id='code_folder_mainarea_new_item_unzip' name='code_folder_new_item_unzip' value='yes'/><?php print $this->lang->line('Unzip a zip file'); ?></div>
|
<div><input type='checkbox' id='code_folder_mainarea_new_item_unzip' name='code_folder_new_item_unzip' value='yes'/><?php print $this->lang->line('Unzip a zip file'); ?></div>
|
||||||
<div><ul id='code_folder_mainarea_new_file_form_item_list'></ul></div>
|
<div><ul id='code_folder_mainarea_new_file_list'></ul></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="code_folder_mainarea_new_dir_div">
|
<div id="code_folder_mainarea_new_dir_div">
|
||||||
<div><ul id='code_folder_mainarea_new_dir_form_item_list'></ul></div>
|
<div><ul id='code_folder_mainarea_new_dir_list'></ul></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="code_folder_mainarea_new_empfile_div">
|
<div id="code_folder_mainarea_new_empfile_div">
|
||||||
<div><ul id='code_folder_mainarea_new_empfile_form_item_list'></ul></div>
|
<div><ul id='code_folder_mainarea_new_empfile_list'></ul></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -979,11 +1109,18 @@ $this->load->view (
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="code_folder_mainarea_delete_form_div">
|
<div id="code_folder_mainarea_delete_form_div">
|
||||||
<div><span id='code_folder_mainarea_delete_display_message'></span><br /> </div>
|
|
||||||
<div><?php print $this->lang->line('Message'); ?>:</div>
|
<div><?php print $this->lang->line('Message'); ?>:</div>
|
||||||
<div><textarea type='textarea' id='code_folder_mainarea_delete_message' name='code_folder_delete_message' style='width:100%;' ></textarea></div>
|
<div><textarea type='textarea' id='code_folder_mainarea_delete_message' name='code_folder_delete_message' style='width:100%;' ></textarea></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="code_folder_mainarea_rename_form_div">
|
||||||
|
<div><?php print $this->lang->line('Message'); ?>:</div>
|
||||||
|
<div><textarea type='textarea' id='code_folder_mainarea_rename_message' name='code_folder_rename_message' style='width:100%;' ></textarea></div>
|
||||||
|
<div id="code_folder_mainarea_rename_file_div">
|
||||||
|
<div><table id='code_folder_mainarea_rename_file_table'></table></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div id='code_folder_mainarea_alert'></div>
|
<div id='code_folder_mainarea_alert'></div>
|
||||||
|
@ -382,6 +382,26 @@ function codepot_htmlspecialchars(string, quote_style, charset, double_encode) {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function codepot_addslashes(str) {
|
||||||
|
// discuss at: http://phpjs.org/functions/addslashes/
|
||||||
|
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||||
|
// improved by: Ates Goral (http://magnetiq.com)
|
||||||
|
// improved by: marrtins
|
||||||
|
// improved by: Nate
|
||||||
|
// improved by: Onno Marsman
|
||||||
|
// improved by: Brett Zamir (http://brett-zamir.me)
|
||||||
|
// improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
|
||||||
|
// input by: Denny Wardhana
|
||||||
|
// example 1: addslashes("kevin's birthday");
|
||||||
|
// returns 1: "kevin\\'s birthday"
|
||||||
|
|
||||||
|
return (str + '')
|
||||||
|
.replace(/[\\"']/g, '\\$&')
|
||||||
|
.replace(/\u0000/g, '\\0');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function codepot_ascii_to_hex (x)
|
function codepot_ascii_to_hex (x)
|
||||||
{
|
{
|
||||||
var r="";
|
var r="";
|
||||||
|
Loading…
Reference in New Issue
Block a user