diff --git a/codepot/src/codepot/controllers/main.php b/codepot/src/codepot/controllers/main.php index c4fb0689..b0808abd 100644 --- a/codepot/src/codepot/controllers/main.php +++ b/codepot/src/codepot/controllers/main.php @@ -32,7 +32,7 @@ class Main extends Controller $data['message'] = ''; - if($this->input->post('login')) + if($this->input->post('user_name')) { $user_name = $this->input->post('user_name'); $user_pass = $this->input->post('user_pass'); diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index 428a7fdd..7af53fca 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -52,7 +52,6 @@ class Project extends Controller $this->load->library ('pagination'); - if ($filter == '' && $offset == '') { $offset = 0; @@ -463,6 +462,36 @@ class Project extends Controller $this->load->view ($this->VIEW_LOG, $data); } } + + function search_json ($needle = '') + { + $this->load->model ('ProjectModel', 'projects'); + + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + { + $projects = array (); + } + else if (empty($needle)) + { + // return no result if $needle is empty + $projects = array (); + } + else + { + $projects = $this->projects->findIDsAndNames ($login['id'], $needle); + if ($projects === FALSE) + { + $projects = array (); + } + } + + foreach ($projects as &$p) + { + $p->value = $p->id . ' - ' . $p->value; + } + print codepot_json_encode ($projects); + } } ?> diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 5de0ca1b..874b3dc8 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -69,6 +69,7 @@ $lang['Path'] = 'Path'; $lang['Preview'] = 'Preview'; $lang['Priority'] = 'Priority'; $lang['Project'] = 'Project'; +$lang['Project ID'] = 'Project ID'; $lang['Projects'] = 'Projects'; $lang['Public'] = 'Public'; $lang['Purge'] = 'Purge'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index 45a63efd..a935fcff 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -67,6 +67,7 @@ $lang['Path'] = 'Path'; $lang['Preview'] = 'Preview'; $lang['Priority'] = 'Pirority'; $lang['Project'] = 'Proyek'; +$lang['Project ID'] = 'Proyek ID'; $lang['Projects'] = 'Proyek'; $lang['Public'] = 'Public'; $lang['Purge'] = 'Purge'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index a8761a81..65b97695 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -69,6 +69,7 @@ $lang['Path'] = '경로'; $lang['Preview'] = '미리보기'; $lang['Priority'] = '중요도'; $lang['Project'] = '프로젝트'; +$lang['Project ID'] = '프로젝트 아이디'; $lang['Projects'] = '프로젝트'; $lang['Public'] = '공개'; $lang['Purge'] = '정화하기'; diff --git a/codepot/src/codepot/models/projectmodel.php b/codepot/src/codepot/models/projectmodel.php index 76a57bfa..358a27df 100644 --- a/codepot/src/codepot/models/projectmodel.php +++ b/codepot/src/codepot/models/projectmodel.php @@ -92,6 +92,18 @@ class ProjectModel extends Model return $query->result (); } + function findIDsAndNames ($userid, $needle) + { + $this->db->trans_start (); + $this->db->select(array('id', 'name as value')); // jquery ui autocomplete seems to require 'value'. + $this->db->order_by ('id', 'asc'); + $this->db->like ('id', $needle); + $this->db->or_like ('name', $needle); + $query = $this->db->get ('project'); + $this->db->trans_complete (); + if ($this->db->trans_status() === FALSE) return FALSE; + return $query->result (); + } function create ($userid, $project, $api_base_url) { diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 266b1f38..47ed0fb1 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -287,7 +287,6 @@ class SubversionModel extends Model function _get_diff ($diff, $src1, $src2, $all, $ent) { /* copied from websvn */ - if ($all) { //$ofile = fopen ($oldtname, "r"); @@ -315,7 +314,8 @@ class SubversionModel extends Model $curoline = 1; $curnline = 1; - while (!feof($diff)) + $abort = FALSE; + while (!feof($diff) && !$abort) { // Get the first line of this range sscanf($line, "@@ -%d", $oline); @@ -378,13 +378,43 @@ class SubversionModel extends Model $index++; } - $fin = false; + $fin = FALSE; while (!feof($diff) && !$fin) { $line = fgets($diff); - if ($line === false || strncmp($line, "@@", 2) == 0) + if ($line === FALSE || $line == "\n") { - $fin = true; + // fgets() returned failure or an empty line has been read. + // An empty line can be read if property changes exist. + // The line before 'Property changes on: ..' is an empty line. + // + // Index: test1.txt + // =================================================================== + // --- test1.txt (revision 14) + // +++ test1.txt (working copy) + // @@ -1 +1,6 @@ + // hello world + // + + // + + // +hello world 2 + // + + // +hello world 3 + // + // Property changes on: test1.txt + // ___________________________________________________________________ + // Added: test + // + xxx + // Added: abcprop + // + on + // Deleted: svn:executable + // - * + // + $fin = TRUE; + $abort = TRUE; + } + else if (strncmp($line, "@@", 2) == 0) + { + $fin = TRUE; } else { @@ -454,7 +484,6 @@ class SubversionModel extends Model $curnline++; } - // Don't increment the current index count $index--; @@ -526,7 +555,6 @@ class SubversionModel extends Model //$listing[$index]["rev1line"] = " "; $listing[$index]["rev1line"] = ''; } - if (!feof($nfile)) { @@ -645,7 +673,7 @@ class SubversionModel extends Model [last_changed_rev] => 27 [last_changed_date] => 2010-02-18T01:53:13.076062Z [last_changed_author] => hyunghwan - ) + ) */ $fileinfo['fullpath'] = substr ( diff --git a/codepot/src/codepot/views/code_blame.php b/codepot/src/codepot/views/code_blame.php index 4278c3f1..c1d9567d 100644 --- a/codepot/src/codepot/views/code_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -47,6 +47,8 @@ $(function () { "option", "label", "lang->line('Hide details')?>"); } }); + + prettyPrint (); }); @@ -58,7 +60,7 @@ $(function () { ?> - +
diff --git a/codepot/src/codepot/views/code_diff.php b/codepot/src/codepot/views/code_diff.php index 5875eab4..405525d1 100644 --- a/codepot/src/codepot/views/code_diff.php +++ b/codepot/src/codepot/views/code_diff.php @@ -16,6 +16,12 @@ + + <?php if ($headpath == '') printf ('%s', htmlspecialchars($project->name)); @@ -24,7 +30,7 @@ ?> - +
@@ -161,7 +167,7 @@ function format_diff2 ($a, $b, $css_class) $cc .= ''; } $cc .= htmlspecialchars(substr($a, $mp1, $ml)); - $k = $mp1 + $ml; + $k = $mp1 + $ml; } if ($k < strlen($a)) { @@ -348,7 +354,7 @@ if (FALSE) // don't want to delete code for the original diff view. print $x['rev1lineno']; print ''; } - + if (array_key_exists('rev2line', $x)) { $diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff'; @@ -398,11 +404,11 @@ else $prevanc = "code/fulldiff/{$project->id}/{$xpar}/{$currev}/{$prevrev}"; print anchor ($prevanc, '<<'); print '   '; - + print $this->lang->line('Revision'); print ' '; print $file['against']['created_rev']; - + $currev = $file['created_rev']; $nextrev = $file['against']['next_rev']; $nextanc = "code/fulldiff/{$project->id}/{$xpar}/{$currev}/{$nextrev}"; @@ -443,7 +449,6 @@ else printf ("
"); print ''; - print ("
"); print "