source: Dev/trunk/classes/pipelineSequencer.php @ 144

Last change on this file since 144 was 144, checked in by fpvanagthoven, 13 years ago

Fixed mkdir call in ApplicationConnector?.php, now actually makes a directory instead of errors.
Cleaning up of pipeline Sequencer, smaller icons, etc. Trying to get non-db version of editor working properly, then integrate db calls.

File size: 3.8 KB
Line 
1<?php
2/*
3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7/**
8 * Description of Sequencer
9 *
10 * @author HP
11 */
12class pipelineSequencer {
13
14    // properties
15    private $steps;
16    private $title = "testSequencer";
17    private $id = 1;
18    private $numStepsInArray = 0;
19    private $maxNumStepsInArray = 8;
20    private $selectedStep;
21
22    public function __construct($steps) {
23        $this->steps = $steps;
24        $this->selectedStep = $this->steps[2];
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>';
34        ?>
35        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
36                <div class="title">Name: <?php echo $this->title; ?> </div>
37
38                <div class="seqContent">
39                    <?php $this->drawSteps(); ?>         
40                </div>
41
42                <div id="controls">
43                    <input type="submit" name="moveSelectedLeft" value="< Move" class="surveyButton" />
44                    <input type="submit" name="moveSelectedRight" value="Move >" class="surveyButton" />
45                    <input type="submit" name="editSelected" value="Edit step" class="surveyButton" />
46                    <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?
49                    <input type="hidden" name="selectedStep" />
50                </div>
51            </fieldset>
52        </form>
53        <?php
54    }
55
56    public function AddStep($step) {
57        $this->steps[] = $step;
58        ?>
59        <script type="text/javascript">
60            document.refresh();
61        </script>
62        <?php
63    }
64
65    public function RemoveStep($targetStep) {
66
67        $tempArray;
68        foreach ($this->steps as $step) {
69            if ($step != targetStep) {
70                $tempArray[] = $step;
71            }
72        }
73        $this->steps = $tempArray;
74    }
75
76    public function GetSteps() {
77        return $this->steps;
78    }
79
80    public function drawSteps() {
81        //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>";
88                }
89            }
90        }
91    }
92
93    public function moveStep($direction) {
94        $key = array_search($this->selectedStep, $this->steps);
95        echo $key;
96    }
97
98    private function moveEntry(&$array, $key, $dir) {
99        if ($dir == -1) {   // move up
100            if ($key > 0) {
101                $reverseArray = array_reverse(array_slice($array, $key - 1, 2, true));   // make a reversed array of the two entries, preserving keys
102                array_splice($array, $key - 1, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
103            }
104        } else if ($dir == 1) {   // move down
105            if ($key < count($array) - 1) {
106                $reverseArray = array_reverse(array_slice($array, $key, 2, true));   // make a reversed array of the two entries, preserving keys
107                array_splice($array, $key, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
108            }
109        }
110    }
111
112}
113?>
Note: See TracBrowser for help on using the repository browser.