Changeset 146 for Dev/trunk/classes/pipelineSequencer.php
- Timestamp:
- 11/07/11 14:41:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/pipelineSequencer.php
r144 r146 10 10 * @author HP 11 11 */ 12 class pipelineSequencer {12 class PipelineSequencer { 13 13 14 14 // properties 15 private $steps; 16 private $title = "testSequencer"; 17 private $id = 1; 15 private $pipeline = array(); 16 private $name = "testSequencer"; 18 17 private $numStepsInArray = 0; 19 private $maxNumStepsInArray = 8;18 private $maxNumStepsInArray = 10; 20 19 private $selectedStep; 21 20 22 public function __construct($steps) { 23 $this->steps = $steps; 24 $this->selectedStep = $this->steps[2]; 21 public function __construct($pipeline, $name, $id) { 22 $this->pipeline = $pipeline; 23 $this->name = $name; 24 } 25 25 26 $this->moveStep(1); 27 28 // echo '<br /><fieldset id="sequencer">'."\n\n"; 29 // echo '<div class="title">Name: '.$this->title.'</div>'; 30 // echo '<div class="seqContent">'."\n\n"; 31 // echo ''; 32 // echo '</div>'; 33 // echo '</fieldset>'; 26 public function DrawSequencer() { 34 27 ?> 35 28 <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer"> 36 <div class="title">Name: <?php echo $this-> title; ?> </div>29 <div class="title">Name: <?php echo $this->name; ?> </div> 37 30 38 31 <div class="seqContent"> 39 <?php $this-> drawSteps(); ?>32 <?php $this->DrawSteps(); ?> 40 33 </div> 41 34 … … 45 38 <input type="submit" name="editSelected" value="Edit step" class="surveyButton" /> 46 39 <input type="submit" name="deleteSelected" value="Delete step" class="surveyButton" /> 47 <input type="submit" name="clearPipeline" value="Clear pipeline" class=" " disabled="true"/>48 <input type="checkbox" name="confirmClear" />Really clear?40 <input type="submit" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/> 41 <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear? 49 42 <input type="hidden" name="selectedStep" /> 50 43 </div> … … 54 47 } 55 48 56 public function AddStep($step) { 57 $this->steps[] = $step; 49 public function AddStep($newStep) { 50 $n = 1; 51 foreach ($this->pipeline as $existingStep) { 52 if ($existingStep->name == $newStep . " $n") { 53 $n++; 54 } 55 } 56 57 $this->pipeline[] = new Step($newStep, $newStep . " " . $n, count($this->pipeline) + 1); 58 //var_dump($this->pipeline); 58 59 ?> 59 60 <script type="text/javascript"> … … 65 66 public function RemoveStep($targetStep) { 66 67 67 $tempArray; 68 foreach ($this->steps as $step) { 69 if ($step != targetStep) { 68 $tempArray = array(); 69 $removed = false; 70 foreach ($this->pipeline as $step) { 71 if ($step->id != $targetStep) { 70 72 $tempArray[] = $step; 73 if ($removed) { 74 $step::AdjustID(-1); 75 } 76 } else { 77 $removed = true; 71 78 } 72 79 } 73 $this-> steps= $tempArray;80 $this->pipeline = $tempArray; 74 81 } 75 82 76 public function Get Steps() {77 return $this-> steps;83 public function GetPipeline() { 84 return $this->pipeline; 78 85 } 79 86 80 public function drawSteps() {87 public function DrawSteps() { 81 88 //draw the actual icons in the container div. 82 foreach ($this->steps as $step) { 83 if ($this->numStepsInArray < $this->maxNumStepsInArray) { 84 new DisplayStep($step->type, null, $step->name, $step->id); 85 $this->numStepsInArray++; 86 if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->steps)) { 87 echo "<div class='divider'></div>"; 89 if (!empty($this->pipeline)) { 90 foreach ($this->pipeline as $step) { 91 if ($this->numStepsInArray < $this->maxNumStepsInArray) { 92 //var_dump($step); 93 $step->DrawStep(); 94 $this->numStepsInArray++; 95 if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->pipeline)) { 96 echo "<div class='divider'></div>"; 97 } 88 98 } 89 99 } … … 91 101 } 92 102 93 public function moveStep($direction) {94 $key = array_search($this->selectedStep, $this-> steps);95 echo $key;103 public function MoveStep($direction) { 104 $key = array_search($this->selectedStep, $this->pipeline); 105 //echo $key; 96 106 } 97 107 98 private function moveEntry(&$array, $key, $dir) {108 private function MoveEntry(&$array, $key, $dir) { 99 109 if ($dir == -1) { // move up 100 110 if ($key > 0) { … … 110 120 } 111 121 122 public function SetSelected($key) { 123 124 if ($key > 0 && $key < count($this->pipeline)) { 125 $this->selectedStep = $key; 126 } 127 } 128 129 public function GetName($name) { 130 if ($name && $name != "") { 131 $this->name = $name; 132 } 133 } 134 135 public function GetFromDB() { 136 137 if (isset($_POST['destroy'])) { 138 unset($_POST['destroy']); 139 unset($_SESSION['currentPipeline']); 140 } 141 142 if (isset($_POST['clearPipeline'])) { 143 $this->pipeline = array(); 144 $_SESSION['currentPipeline'] = $this->pipeline; 145 } 146 147 if (isset($_SESSION['currentPipeline']) && !empty($_SESSION['currentPipeline'])) { // take pipeline from session data 148 $this->pipeline = $_SESSION['currentPipeline']; 149 } else { 150 $pipeline = array(); 151 } 152 153 if (isset($_POST['objectToCreate'])) { // user clicked a button in the toolbox. 154 //$this->pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate'] . " NEW", null); 155 $this::AddStep($_POST['objectToCreate']); 156 } 157 158 if (isset($_POST['deleteSelected'])) { 159 if (isset($_POST['selectedStep'])) { 160 $this->RemoveStep($_POST['selectedStep']); 161 } 162 } 163 164 //var_dump($_POST); 165 166 if (isset($_POST['selectedStep'])) { 167 $this::SetSelected($_POST['selectedStep']); 168 } 169 170 $_SESSION['currentPipeline'] = $this->pipeline; 171 } 172 112 173 } 113 174 ?>
Note: See TracChangeset
for help on using the changeset viewer.