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
20 if (!isset($_REQUEST['ajax_body'])) {
23 $this->masterTemplate = 'log.html';
26 $this->pi = empty($pi) ? '' : ($pi . $this->bootLoader->ext);
28 $this->repo = DB_DataObject::factory('mtrack_repos');
29 $this->filename = $this->repo->loadFromPath($this->pi);
32 if (!$this->repo->id) {
33 return HTML_FlexyFramework::run('Browse');
36 if (!$this->projectPerm($this->repo->project_id, 'MTrack.Repos', 'S')) {
37 return HTML_FlexyFramework::run('Noperm'); // noperm = loggedin -> need more perms / not.. try loggin in..
42 $this->branches = $this->repo->getBranches();
46 $this->title = "Log $this->filename";
48 $this->branches = $this->repo->getBranches();
51 $this->crumbs = array();
53 $this->basename = basename($this->filename);
54 $crumbs = dirname($this->filename) == '.' ? array() : explode('/', dirname($this->filename));
56 array_unshift($crumbs,'');
57 foreach($crumbs as $path)
61 $c->name = strlen($path) ? $path : '[root]';
62 $c->root = strlen($path) ? 0 : 1;
63 $location .= strlen($location) ? '/' : '';
64 $location .= strlen($path) ? urlencode($path) : '';
65 $c->location = $location;
69 $branches = $this->repo->getBranches();
70 $tags = $this->repo->getTags();
71 if (count($branches) + count($tags)) {
73 $jumps = array("" => "- Select Branch / Tag - ");
74 if (is_array($branches)) {
75 foreach ($branches as $name => $notcare) {
76 $jumps["branch:$name"] = "Branch: $name";
79 if (is_array($tags)) {
80 foreach ($tags as $name => $notcare) {
81 $jumps["tag:$name"] = "Tag: $name";
85 $this->elements['jump'] = new HTML_Template_Flexy_Element('select');
86 $this->elements['jump']->setOptions($jumps);
87 $this->elements['jump']->setValue(empty($_GET['jump']) ? '' : $_GET['jump']);
91 if (!empty($_GET['jump'])) {
92 list($object, $ident) = explode(':', $_GET['jump'], 2);
98 $hist = $this->repo->history($this->filename, 100, $object, $ident);
105 // repo has a 'release' branch, this should be used to track what needs
106 // merging from 'HEAD' to update it
107 // (basically how far behind is the release from head..)
109 // $need_review = ' style="background-color:#fdd;"';
110 // $good_to_go = ' style="background-color:#585;"';
111 // $live = ' style="background-color:#336;"';
114 $this->hist= array();
115 foreach($hist as $i=>$h) {
116 $h->cls = $i % 2 ? 'odd' : '';
118 $ts = strtotime($h->ctime);
119 $day = date('D, M d Y', $ts);
120 $time = date('g:ia', $ts);
122 if ($day !== $last_day) {
123 $this->hist[] = (object) array(
132 if (preg_match('/#([0-9]+)\s+/', $h->changelog, $M)) {
134 $h->ticket = MTrackIssue::loadByNSIdent($M[1]) ;
135 // ticket->status == closed == ok to commit to another branch...
136 // echo '<PRE>'; print_r($h->ticket);