enhanced code search.
added configuration items: allow_set_time_limit and signin_for_code_search
This commit is contained in:
parent
73efd665cc
commit
197df5adc3
@ -173,6 +173,20 @@ log_threshold = 0
|
||||
;------------------------------------------------------------------------------
|
||||
force_project_delete = "no"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; When yes, a codepot page can use set_time_limit() to adjust the maximum
|
||||
; execution time to override the global value. For example, the code search
|
||||
; page can take very long if the code repository is very large. You can
|
||||
; set this item to yes to allow such a page to complete its processing.
|
||||
;------------------------------------------------------------------------------
|
||||
allow_set_time_limit = "no"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; When yes, a user must sign in to be able to search code.
|
||||
; When no, an anonymous user can search code.
|
||||
;------------------------------------------------------------------------------
|
||||
signin_for_code_search = "yes"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; customized footer
|
||||
;------------------------------------------------------------------------------
|
||||
|
@ -507,7 +507,7 @@ class Code extends Controller
|
||||
$this->load->model ('SubversionModel', 'subversion');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
if ((CODEPOT_SIGNIN_COMPULSORY || CODEPOT_SIGNIN_FOR_CODE_SEARCH) && $login['id'] == '')
|
||||
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
|
||||
|
||||
$project = $this->projects->get ($projectid);
|
||||
@ -533,7 +533,6 @@ class Code extends Controller
|
||||
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
|
||||
}
|
||||
|
||||
|
||||
$this->_search_code ($project, $login);
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,6 @@ $lang['CODE_PROPERTY'] = 'Property';
|
||||
|
||||
$lang['CODE_MSG_COMMITTED_BY'] = 'Committed by %s';
|
||||
$lang['CODE_MSG_COMMITTED_BY_ON'] = 'Committed by %s on %s';
|
||||
|
||||
$lang['CODE_BAD_SEARCH_PATTERN'] = 'Bad search pattern';
|
||||
?>
|
||||
|
@ -3,7 +3,6 @@ $lang['Administration'] = 'Administration';
|
||||
$lang['All'] = 'All';
|
||||
$lang['Attachment'] = 'Attachment';
|
||||
$lang['Attachments'] = 'Attachments';
|
||||
$lang['Author'] = 'Author';
|
||||
$lang['Blame'] = 'Blame';
|
||||
$lang['Cancel'] = 'Cancel';
|
||||
$lang['Change'] = 'Change';
|
||||
@ -12,6 +11,7 @@ $lang['Code'] = 'Code';
|
||||
$lang['Code changes'] = 'Code changes';
|
||||
$lang['Comment'] = 'Comment';
|
||||
$lang['Commitable'] = 'Commitable';
|
||||
$lang['Commiter'] = 'Commiter';
|
||||
$lang['Create'] = 'Create';
|
||||
$lang['Created by'] = 'Created by';
|
||||
$lang['Created on'] = 'Created on';
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
$lang['Administration'] = 'Administration';
|
||||
$lang['All'] = 'Semua';
|
||||
$lang['Author'] = 'Pengarang';
|
||||
$lang['Blame'] = 'Menyalahkan';
|
||||
$lang['Cancel'] = 'Cancel';
|
||||
$lang['Change'] = 'Change';
|
||||
@ -10,6 +9,7 @@ $lang['Code'] = 'Kode';
|
||||
$lang['Code changes'] = 'Kode changes'
|
||||
$lang['Comment'] = 'Comment';
|
||||
$lang['Commitable'] = 'Commitable';
|
||||
$lang['Commiter'] = 'Pengarang';
|
||||
$lang['Create'] = 'Dibuat';
|
||||
$lang['Created by'] = 'Dibuat oleh';
|
||||
$lang['Created on'] = 'Waktu dibuat';
|
||||
|
@ -3,6 +3,8 @@ $lang['CODE_COMMIT'] = '커밋';
|
||||
$lang['CODE_PROPERTIES'] = '속성';
|
||||
$lang['CODE_PROPERTY'] = '속성';
|
||||
|
||||
$lang['CODE_MSG_COMMITTED_BY'] = '%s이(가) 커밋함';
|
||||
$lang['CODE_MSG_COMMITTED_BY_ON'] = '%s이(가) %s에 커밋함';
|
||||
$lang['CODE_MSG_COMMITTED_BY'] = '커밋터 %s';
|
||||
$lang['CODE_MSG_COMMITTED_BY_ON'] = '커밋터 %s 시간 %s';
|
||||
|
||||
$lang['CODE_BAD_SEARCH_PATTERN'] = '검색패턴이 잘못되었습니다';
|
||||
?>
|
||||
|
@ -3,7 +3,6 @@ $lang['Administration'] = '관리';
|
||||
$lang['All'] = '모두';
|
||||
$lang['Attachment'] = '첨부';
|
||||
$lang['Attachments'] = '첨부';
|
||||
$lang['Author'] = '저자';
|
||||
$lang['Blame'] = '책임전가';
|
||||
$lang['Cancel'] = '취소';
|
||||
$lang['Change'] = '변경';
|
||||
@ -12,6 +11,7 @@ $lang['Code'] = '코드';
|
||||
$lang['Code changes'] = '코드변경';
|
||||
$lang['Comment'] = '소견';
|
||||
$lang['Commitable'] = '커밋가능';
|
||||
$lang['Commiter'] = '커밋터';
|
||||
$lang['Create'] = '생성';
|
||||
$lang['Created by'] = '최초생성인';
|
||||
$lang['Created on'] = '최초생성시간';
|
||||
@ -87,12 +87,12 @@ $lang['Username'] = '사용자명';
|
||||
$lang['Wiki'] = '위키';
|
||||
$lang['Wikis'] = '위키';
|
||||
|
||||
$lang['MSG_LOG_COMMIT_BY'] = '%s이(가) 커밋했습니다';
|
||||
$lang['MSG_LOG_CHANGE_BY'] = '%s이(가) 변경했습니다';
|
||||
$lang['MSG_LOG_CREATE_BY'] = '%s이(가) 생성했습니다';
|
||||
$lang['MSG_LOG_DELETE_BY'] = '%s이(가) 삭제했습니다';
|
||||
$lang['MSG_LOG_UPDATE_BY'] = '%s이(가) 갱신했습니다';
|
||||
$lang['MSG_LOG_REVPROP_CHANGE_BY'] = '리비전 속성 %s을(를) %s이(가) 변경했습니다';
|
||||
$lang['MSG_LOG_COMMIT_BY'] = '%s 커밋';
|
||||
$lang['MSG_LOG_CHANGE_BY'] = '%s 변경';
|
||||
$lang['MSG_LOG_CREATE_BY'] = '%s 생성';
|
||||
$lang['MSG_LOG_DELETE_BY'] = '%s 삭제';
|
||||
$lang['MSG_LOG_UPDATE_BY'] = '%s 갱신';
|
||||
$lang['MSG_LOG_REVPROP_CHANGE_BY'] = '리비전속성 %s 변경. 변경자 %s';
|
||||
|
||||
|
||||
$lang['MSG_NO_DIFF'] = '차이점이 없습니다';
|
||||
|
@ -184,7 +184,7 @@ $this->load->view (
|
||||
print '<th>' . $this->lang->line('Name') . '</th>';
|
||||
print '<th>' . $this->lang->line('Revision') . '</th>';
|
||||
print '<th>' . $this->lang->line('Size') . '</th>';
|
||||
print '<th>' . $this->lang->line('Author') . '</th>';
|
||||
print '<th>' . $this->lang->line('Commiter') . '</th>';
|
||||
print '<th>' . $this->lang->line('Date') . '</th>';
|
||||
print '<th>' . $this->lang->line('Blame') . '</th>';
|
||||
print '<th>' . $this->lang->line('Difference') . '</th>';
|
||||
|
@ -82,7 +82,7 @@ $this->load->view (
|
||||
<table id="code_history_mainarea_result_table">
|
||||
<tr class='heading'>
|
||||
<th><?=$this->lang->line('Revision')?></th>
|
||||
<th><?=$this->lang->line('Author')?></th>
|
||||
<th><?=$this->lang->line('Commiter')?></th>
|
||||
<th><?=$this->lang->line('Date')?></th>
|
||||
<th><?=$this->lang->line('Message')?></th>
|
||||
<?php if ($file['type'] == 'file' || $file['type'] == 'dir') print '<th></th>'; ?>
|
||||
|
@ -111,7 +111,7 @@ $history = $file['history'];
|
||||
<?=anchor ("code/revision/{$project->id}/${xpar}/{$prev_revision}", '<<')?>
|
||||
<?=$this->lang->line('Revision')?>: <?=$history['rev']?>
|
||||
<?=anchor ("code/revision/{$project->id}/${xpar}/{$next_revision}", '>>')?> |
|
||||
<?=$this->lang->line('Author')?>: <?=htmlspecialchars($history['author'])?> |
|
||||
<?=$this->lang->line('Committer')?>: <?=htmlspecialchars($history['author'])?> |
|
||||
<?=$this->lang->line('Last updated on')?>: <?=date('r', strtotime($history['date']))?>
|
||||
</div>
|
||||
|
||||
|
@ -106,15 +106,19 @@ $this->load->view (
|
||||
<div id="code_search_mainarea_result">
|
||||
|
||||
<?php
|
||||
function search_and_show ($controller, $project, $file, $revision, $pattern)
|
||||
function search_and_show ($controller, $project, $path, $revision, $pattern, $recurse)
|
||||
{
|
||||
if ($file['type'] == 'file')
|
||||
{
|
||||
// this function must be called with a directory
|
||||
// do nothing here.
|
||||
}
|
||||
else
|
||||
//$file = $controller->subversion->getFile ($project->id, $path, $revision);
|
||||
//if ($file['type'] == 'file') return;
|
||||
|
||||
$dirarray = array ($path);
|
||||
|
||||
while (count($dirarray) > 0)
|
||||
{
|
||||
$path = array_shift ($dirarray);
|
||||
$file = $controller->subversion->getFile ($project->id, $path, $revision);
|
||||
if ($file === FALSE || $file['type'] == 'file') continue;;
|
||||
|
||||
// search in a directory.
|
||||
$file_list = $file['content'];
|
||||
foreach ($file_list as $f)
|
||||
@ -127,8 +131,15 @@ function search_and_show ($controller, $project, $file, $revision, $pattern)
|
||||
{
|
||||
$lines = explode ("\n", $file2['content']);
|
||||
//$matchkeys = preg_grep ("/{$pattern}/i", $lines, 0);
|
||||
$matchlines = preg_grep ("/{$pattern}/", $lines, 0);
|
||||
if (count($matchlines) > 0)
|
||||
// TODO: allow regular expression
|
||||
$escaped_pattern = preg_quote ($pattern, '/');
|
||||
$matchlines = @preg_grep ("/{$pattern}/", $lines, 0);
|
||||
if ($matchlines === FALSE)
|
||||
{
|
||||
print $controller->lang->line('CODE_BAD_SEARCH_PATTERN');
|
||||
return;
|
||||
}
|
||||
else if (count($matchlines) > 0)
|
||||
{
|
||||
$hexpath = $controller->converter->AsciiToHex($fullpath);
|
||||
if ($revision <= 0)
|
||||
@ -161,15 +172,23 @@ function search_and_show ($controller, $project, $file, $revision, $pattern)
|
||||
}
|
||||
else
|
||||
{
|
||||
search_and_show ($controller, $project, $file2, $revision, $pattern);
|
||||
|
||||
if ($recurse && count($file2['content']) > 0)
|
||||
{
|
||||
array_push ($dirarray, $fullpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->subversion->getFile ($project->id, $file['fullpath'], $revision);
|
||||
search_and_show ($this, $project, $file, $revision, $pattern);
|
||||
// the repository search can take very long.
|
||||
// change the execution time limit to run this script forever if it's allowed.
|
||||
if (CODEPOT_ALLOW_SET_TIME_LIMIT) set_time_limit (0);
|
||||
|
||||
// TODO: prevent recursion to subdirectories depending on input
|
||||
search_and_show ($this, $project, $file['fullpath'], $revision, $pattern, TRUE);
|
||||
?>
|
||||
|
||||
</div> <!-- code_search_mainarea_result -->
|
||||
|
@ -74,6 +74,9 @@ function load_ini ($file)
|
||||
array ('log_threshold', 'integer', 0),
|
||||
|
||||
array ('force_project_delete', 'boolean', FALSE),
|
||||
array ('allow_set_time_limit', 'boolean', FALSE),
|
||||
array ('signin_for_code_search', 'boolean', TRUE),
|
||||
|
||||
array ('footer', 'string', '')
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user