1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
4 require_once 'MTrackWeb.php';
6 class MTrackWeb_Log extends MTrackWeb
8 var $template = 'log.html';
20 if (!empty($_REQUEST['embed'])) {
21 $this->masterTemplate=$this->template;
24 $this->pi = empty($pi) ? '' : ($pi . $this->bootLoader->ext);
26 $this->repo = DB_DataObject::factory('mtrack_repos');
27 $this->filename = $this->repo->loadFromPath($this->pi);
30 if (!$this->repo->id) {
31 return HTML_FlexyFramework::run('Browse');
34 if (!$this->projectPerm($this->repo->project_id, 'MTrack.Repos', 'S')) {
35 return HTML_FlexyFramework::run('Noperm'); // noperm = loggedin -> need more perms / not.. try loggin in..
40 $this->branches = $this->repo->getBranches();
44 $this->title = "Log $this->filename";
46 $this->branches = $this->repo->getBranches();
49 $this->crumbs = array();
51 $crumbs = explode('/', $file);
52 array_unshift($crumbs,'');
53 foreach($crumbs as $path)
57 $c->name = strlen($path) ? $path : '[root]';
58 $c->root = strlen($path) ? 0 : 1;
59 $location .= strlen($location) ? '/' : '';
60 $location .= strlen($path) ? urlencode($path) : '';
61 $c->location = $location;
65 $branches = $this->repo->getBranches();
66 $tags = $this->repo->getTags();
67 if (count($branches) + count($tags)) {
69 $jumps = array("" => "- Select Branch / Tag - ");
70 if (is_array($branches)) {
71 foreach ($branches as $name => $notcare) {
72 $jumps["branch:$name"] = "Branch: $name";
75 if (is_array($tags)) {
76 foreach ($tags as $name => $notcare) {
77 $jumps["tag:$name"] = "Tag: $name";
81 $this->elements['jump'] = new HTML_Template_Flexy_Element('select');
82 $this->elements['jump']->setOptions($jumps);
83 $this->elements['jump']->setValue(empty($_GET['jump']) ? '' : $_GET['jump']);
87 if (!empty($_GET['jump'])) {
88 list($object, $ident) = explode(':', $_GET['jump'], 2);
94 $hist = $this->repo->history($file, 100, $object, $ident);
101 // repo has a 'release' branch, this should be used to track what needs
102 // merging from 'HEAD' to update it
103 // (basically how far behind is the release from head..)
105 // $need_review = ' style="background-color:#fdd;"';
106 // $good_to_go = ' style="background-color:#585;"';
107 // $live = ' style="background-color:#336;"';
110 $this->hist= array();
111 foreach($hist as $i=>$h) {
112 $h->cls = $i % 2 ? 'odd' : '';
114 $ts = strtotime($h->ctime);
115 $day = date('D, M d Y', $ts);
116 $time = date('g:ia', $ts);
118 if ($day !== $last_day) {
119 $this->hist[] = (object) array(
128 if (preg_match('/#([0-9]+)\s+/', $h->changelog, $M)) {
130 $h->ticket = MTrackIssue::loadByNSIdent($M[1]) ;
131 // ticket->status == closed == ok to commit to another branch...
132 // echo '<PRE>'; print_r($h->ticket);