| <?php |
| require_once 'component.class.php'; |
| require_once 'dependency.class.php'; |
| require_once 'detail.class.php'; |
| |
| class Build { |
| private $label; |
| private $tstamp; |
| private $components = array(); |
| private $type; |
| private $stream; |
| private $dependencies = array(); |
| private $details = array(); |
| |
| function __construct($label, $tstamp, $type, $stream) { |
| $this->label = $label; |
| $this->tstamp = $tstamp; |
| $this->type = $type; |
| $this->stream = $stream; |
| } |
| |
| function getLabel() { |
| return $this->label; |
| } |
| |
| function getTStamp() { |
| return $this->tstamp; |
| } |
| |
| function getType() { |
| return $this->type; |
| } |
| |
| function addComponent($component) { |
| $this->components[] = $component; |
| } |
| |
| function getComponents() { |
| return $this->components; |
| } |
| |
| function getDependencies() { |
| return $this->dependencies; |
| } |
| |
| function addDependency($dependency) { |
| $this->dependencies[] = $dependency; |
| } |
| |
| function getDetails() { |
| return $this->details; |
| } |
| |
| function addDetail($detail) { |
| $this->details[] = $detail; |
| } |
| |
| function render() { |
| |
| global $latestBuild; |
| $isLatest = false; |
| if ( $this->getTStamp() == $latestBuild->getTStamp()) { |
| $isLatest = true; |
| } |
| |
| $year = substr($this->tstamp, 0, 4); |
| $month = substr($this->tstamp, 4, 2); |
| $day = substr($this->tstamp, 6, 2); |
| $hour = substr($this->tstamp,8,2); |
| $minute = substr($this->tstamp,10,2); |
| $timeStamp = mktime($hour, $minute, 0, $month, $day, $year); |
| $date = date("D, j M Y -- H:i (O)", $timeStamp); |
| |
| $result = "<a href=\"javascript:toggle('" . $this->label . "')\"><h4>" . $this->label. " (" . $date . ")</h4></a>"; |
| |
| if ( $isLatest ) { |
| $result = "<a name=\"latest\">" . $result . "</a>"; |
| $result = $result . "<ul id='" . $this->label . "' style='display:block'>"; |
| } else { |
| $result = $result . "<ul id='" . $this->label . "' style='display:none'>"; |
| } |
| |
| foreach( $this->getComponents() as $component ) { |
| $result = $result . "<li>" . $component->render() . "</li>"; |
| } |
| |
| # Show dependencies |
| $result = $result . "<li><h4><img src=\"/tigerstripe/images/dl-deps.gif\"/> Build Dependencies</h4>"; |
| if ( count($this->dependencies) == 0 ) { |
| $result = $result . "<p><small><i>None specified</i></small></p>"; |
| } else { |
| $result = $result . "<ul><li>"; |
| $isFirstDep = true; |
| foreach( $this->dependencies as $dependency ) { |
| if ( !$isFirstDep ) { |
| $result = $result . ", "; |
| } |
| $result = $result . $dependency->render(); |
| $isFirstDep = false; |
| } |
| $result = $result . "</li></ul>"; |
| } |
| $result = $result . "</li>"; |
| |
| # show the rest of the details |
| $result = $result . "<li><h4><img src=\"/tigerstripe/images/dl-more.gif\"/> Build Details</h4>"; |
| if ( count($this->details) == 0 ) { |
| $result = $result . "<p><small><i>None available</i></small></p>"; |
| } else { |
| $result = $result . "<ul><li>"; |
| $isFirstDet = true; |
| foreach( $this->details as $detail ) { |
| if ( !$isFirstDet ) { |
| $result = $result . ", "; |
| } |
| $result = $result . $detail->render(); |
| $isFirstDet = false; |
| } |
| $result = $result . "</li></ul>"; |
| } |
| $result = $result . "</li>"; |
| |
| $result = $result . "</ul>"; |
| |
| return $result; |
| } |
| } |
| |
| ?> |