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';
13 MTrackACL::requireAllRights('Browser', 'read');
20 if (!empty($_REQUEST['embed'])) {
21 $this->masterTemplate=$this->template;
24 $this->pi = empty($pi) ? '' : ($pi . $this->bootLoader->ext);
25 $pi = '/' . $this->pi;
26 if (count(explode('/',$pi)) == 2) {
27 return HTML_FlexyFramework::run('Browse');
30 $crumbs = MTrackSCM::makeBreadcrumbs($pi);
31 if (!strlen($pi) || $pi == '/') {
35 $this->repo = MTrackSCM::factory($pi);
38 if ($this->repo === null) {
39 throw new Exception("Cannot determine what to log from $pi");
42 $this->branches = $this->repo->getBranches();
44 MTrackACL::requireAllRights("repo:{$this->repo->repoid}", 'read');
45 $this->title = "Log $pi";
47 $this->branches = $this->repo->getBranches();
50 $this->crumbs = array();
52 foreach($crumbs as $path)
54 //if (count($this->crumbs) && !strlen($path)) {
58 $c->name = strlen($path) ? $path : '[root]';
59 $c->root = strlen($path) ? 0 : 1;
60 $location .= strlen($location) ? '/' : '';
61 $location .= strlen($path) ? urlencode($path) : '';
62 $c->location = $location;
66 $branches = $this->repo->getBranches();
67 $tags = $this->repo->getTags();
68 if (count($branches) + count($tags)) {
70 $jumps = array("" => "- Select Branch / Tag - ");
71 if (is_array($branches)) {
72 foreach ($branches as $name => $notcare) {
73 $jumps["branch:$name"] = "Branch: $name";
76 if (is_array($tags)) {
77 foreach ($tags as $name => $notcare) {
78 $jumps["tag:$name"] = "Tag: $name";
82 $this->elements['jump'] = new HTML_Template_Flexy_Element('select');
83 $this->elements['jump']->setOptions($jumps);
84 $this->elements['jump']->setValue(empty($_GET['jump']) ? '' : $_GET['jump']);
88 if (!empty($_GET['jump'])) {
89 list($object, $ident) = explode(':', $_GET['jump'], 2);
95 $hist = $this->repo->history($pi, 100, $object, $ident);
102 // repo has a 'release' branch, this should be used to track what needs
103 // merging from 'HEAD' to update it
104 // (basically how far behind is the release from head..)
106 // $need_review = ' style="background-color:#fdd;"';
107 // $good_to_go = ' style="background-color:#585;"';
108 // $live = ' style="background-color:#336;"';
111 $this->hist= array();
112 foreach($hist as $i=>$h) {
113 $h->cls = $i % 2 ? 'odd' : '';
115 $ts = strtotime($h->ctime);
116 $day = date('D, M d Y', $ts);
117 $time = date('g:ia', $ts);
119 if ($day !== $last_day) {
120 $this->hist[] = (object) array(
129 if (preg_match('/#([0-9]+)\s+/', $h->changelog, $M)) {
131 $h->ticket = MTrackIssue::loadByNSIdent($M[1]) ;
132 // ticket->status == closed == ok to commit to another branch...
133 // echo '<PRE>'; print_r($h->ticket);