function displayFeature(Feature $feature, $view, $parent = null) { ob_start(); if ($feature->estimated) { $view->featureEstimate += $feature->estimated; $view->featureCompleted += $feature->status == 'Complete' ? $feature->estimated : 0; } $lateClass = $view->project->actualstart && strtotime($feature->created) > strtotime($view->project->actualstart) ? 'late-feature' : ''; $completeClass = $feature->status == 'Complete' ? 'featureComplete' : ''; $featureId = $feature->id; ?> <li id="featurelist_<?php echo $featureId; ?> " class="<?php echo $lateClass . ' ' . $completeClass; ?> "> <input type="hidden" name="featureId" value="<?php echo $feature->id; ?> " /> <!-- Feature created <?php echo $feature->created; ?> and project started at <?php echo $view->project->actualstart; ?> --> <div class="feature-title"> <h2> <?php $view->dialogPopin('featuredialog', $view->escape($feature->title), build_url('feature', 'edit', array('id' => $feature->id, 'projectid' => $feature->projectid)), array('title' => 'Edit Feature')); ?> </h2> <a title="Delete Feature" href="#" onclick="if (confirm('Are you sure')) $.post('<?php echo build_url('feature', 'delete', array('__validation_token' => $view->requestValidator(true), 'id' => $feature->id)); ?> ', function () { location.reload(false) }); return false;"><img class="small-icon" src="<?php echo resource('images/delete.png'); ?> " /></a> <?php $view->dialogPopin('featuredialog', '<img src="' . resource('images/page_copy.png') . '" />', build_url('feature', 'edit', array('parent' => $feature->id, 'projectid' => $feature->projectid))); ?> </div> <?php if ($feature->estimated) { ?> <div class="feature-body"> <div class="feature-estimate"> <p class="feature-milestone"><?php $view->o($feature->getMilestoneTitle()); ?> </p> <p class="estimate"> <?php $view->o($feature->estimated); ?> </p> </div> <div class="feature-content"> <h3>Description</h3> <p class="feature-description editable-feature" id="feature-<?php echo $feature->id; ?> -description"><?php $view->o($feature->description); ?> </p> <h3>Assumptions</h3> <p class="feature-assumptions editable-feature" id="feature-<?php echo $feature->id; ?> -assumptions"><?php $view->o($feature->assumptions); ?> </p> <h3>Questions</h3> <p class="feature-questions editable-feature" id="feature-<?php echo $feature->id; ?> -questions"><?php $view->o($feature->questions); ?> </p> </div> </div> <?php } ?> <?php $childFeatures = $feature->getChildFeatures(); if (count($childFeatures)) { echo '<ul>'; } $tmpFeature = null; foreach ($feature->getChildFeatures() as $child) { echo displayFeature($child, $view, $feature); $tmpFeature = $child; } if (count($childFeatures)) { echo '</ul>'; } ?> </li><?php $result = ob_get_contents(); ob_end_clean(); return $result; }
function displayFeature(Feature $feature, $view, $pad = 0) { if ($feature->estimated) { $view->featureEstimate += $feature->estimated; $view->featureCompleted += $feature->isComplete() ? $feature->estimated : 0; } $bgcolor = strtotime($feature->created) > strtotime($view->project->started) ? ' style="background-color: #acc"' : ''; ?> <!-- Feature created <?php echo $feature->created; ?> and project started at <?php echo $view->project->started; ?> --> <tr <?php echo $bgcolor; ?> > <td> <?php echo str_repeat(" ", $pad); ?> <?php if ($feature->isComplete()) { ?> <img class="small-icon" src="<?php echo resource('images/accept.png'); ?> " /> <?php } ?> <a title="Show Details" href="<?php echo build_url('feature', 'edit', array('id' => $feature->id, 'projectid' => $feature->projectid)); ?> "><?php $view->o($feature->title); ?> </a> </td> <td><a href="<?php echo build_url('project', 'view', array('id' => $feature->milestone)); ?> "><?php $view->o($feature->getMilestoneTitle()); ?> </a></td> <td style="text-align: center"> <?php $view->o($feature->estimated); ?> </td> <td> <input class="action-icon" type="checkbox" value="<?php $view->o($feature->id); ?> " name="createfrom[]" /> <a title="Delete Feature" href="#" onclick="if (confirm('Are you sure')) location.href='<?php echo build_url('feature', 'delete', array('id' => $feature->id)); ?> '; return false;"><img class="small-icon" src="<?php echo resource('images/delete.png'); ?> " /></a> <a title="Add Child Feature" href="<?php echo build_url('feature', 'edit', array('parent' => $feature->id, 'projectid' => $feature->projectid)); ?> "><img class="small-icon" src="<?php echo resource('images/page_copy.png'); ?> " /></a> </td> </tr> <?php $numberOfChildren = 0; $tmpFeature = null; foreach ($feature->getChildFeatures() as $child) { ++$numberOfChildren; displayFeature($child, $view, $pad + 1); $tmpFeature = $child; } if ($numberOfChildren > 1) { ?> <tr> <td> <?php echo str_repeat(" ", $pad + 1); ?> <a href="<?php echo build_url('feature', 'orderfeatures', array('id' => $feature->id)); ?> " title="Edit feature order" >Order Features</a> </td> <td></td><td></td><td></td> </tr> <?php } }