Пример #1
0
 function addRule(&$node, $instruction)
 {
     $rule = trim($instruction->getRule());
     $rgid = trim($instruction->getRgid());
     if (contains($rule, "//")) {
         $rule = substr($rule, 0, strpos($rule, "//"));
         $instruction->setRule($rule);
     }
     //echo "<hr>" . $rgid . ": " . $rule;
     /* empty line */
     if ($rule == "") {
     } else {
         if (startsWith($rule, ROUTING_IDENTIFY_IF)) {
             $this->addIf($node, $instruction);
             $this->nesting++;
         } else {
             if (startsWith($rule, ROUTING_IDENTIFY_ELSEIF)) {
                 $this->nesting--;
                 $this->addIf($node, $instruction, true);
                 $this->nesting++;
             } else {
                 if (startsWith($rule, ROUTING_IDENTIFY_ELSE)) {
                     $this->nesting--;
                     $this->addElse($node, $instruction, true);
                     $this->nesting++;
                 } else {
                     if (startsWith($rule, ROUTING_IDENTIFY_FOR)) {
                         $this->addForLoop($node, $instruction);
                         $this->nesting++;
                     } else {
                         if (startsWith($rule, ROUTING_IDENTIFY_GROUP)) {
                             $this->addGroup($node, $instruction);
                             $this->nesting++;
                         } else {
                             if (startsWith($rule, ROUTING_IDENTIFY_SUBGROUP)) {
                                 // ONLY if in group
                                 //if (sizeof($this->groups) > 0) {
                                 //    echo 'sub';
                                 $this->addSubGroup($node, $instruction);
                                 //} else { // ignore the subgroup statement
                                 //    $this->cnt = $this->findEndSubGroup($rgid);
                                 //}
                             } else {
                                 if (startsWith($rule, ROUTING_MOVE_FORWARD)) {
                                     $this->addMoveForward($node, $instruction);
                                 } else {
                                     if (startsWith($rule, ROUTING_MOVE_BACKWARD)) {
                                         $this->addMoveBackward($node, $instruction);
                                     } else {
                                         if (contains($rule, ":=")) {
                                             $this->addAssignment($node, $instruction);
                                         } else {
                                             if (startsWith($rule, "/*")) {
                                                 $this->skipComments($this->cnt, $this->cnt);
                                             } else {
                                                 if (startsWith($rule, "//")) {
                                                     /* do nothing */
                                                 } else {
                                                     if (startsWith($rule, ROUTING_IDENTIFY_ENDIF)) {
                                                         $this->addToStatements($this->addEndDashes($this->nesting) . "<div class='uscic-paperversion-endif'>End of if</div></div>", 2);
                                                         $this->nesting--;
                                                     } else {
                                                         if (startsWith($rule, ROUTING_IDENTIFY_ENDDO)) {
                                                             $this->addToStatements($this->addEndDashes($this->nesting) . "<div class='uscic-paperversion-enddo'>End of loop</div></div>", 3);
                                                             $this->nesting--;
                                                         } else {
                                                             if (startsWith($rule, ROUTING_IDENTIFY_ENDGROUP)) {
                                                                 $this->addToStatements($this->addEndDashes($this->nesting) . "<div class='uscic-paperversion-endgroup'>End of group of questions</div></div>", 4);
                                                                 $this->nesting--;
                                                             } else {
                                                                 if (startsWith($rule, ROUTING_IDENTIFY_ENDSUBGROUP)) {
                                                                     $this->addToStatements($this->addEndDashes($this->nesting) . "<div class='uscic-paperversion-endsubgroup'>End of subgroup of questions</div></div>");
                                                                 } else {
                                                                     /* check if this is a section */
                                                                     $mod = $rule;
                                                                     if (contains($rule, ".")) {
                                                                         $mod = substr($rule, strrpos($rule, ".") + 1);
                                                                     }
                                                                     $section = $this->survey->getSectionByName($mod);
                                                                     if ($section->getName() != "") {
                                                                         $gen = new PaperGenerator($this->suid, $this->version, $this->type);
                                                                         $gen->generate($section->getSeid(), $this->nesting);
                                                                         $this->statements = array_merge($this->statements, $gen->getStatements());
                                                                         return;
                                                                     }
                                                                     /* check if this is a question of type section */
                                                                     $var = $this->survey->getVariableDescriptiveByName(getBasicName($rule));
                                                                     if ($var->getAnswerType() == ANSWER_TYPE_SECTION) {
                                                                         $sectionid = $var->getSection();
                                                                         $section = $this->survey->getSection($sectionid);
                                                                         if ($section->getName() != "") {
                                                                             $gen = new PaperGenerator($this->suid, $this->version, $this->type);
                                                                             $gen->generate($section->getSeid(), $this->nesting);
                                                                             $this->statements = array_merge($this->statements, $gen->getStatements());
                                                                         }
                                                                         /* we are done */
                                                                         return;
                                                                     }
                                                                     /* no section of question of type section, then see if it is a question */
                                                                     $rule = trim($instruction->getRule());
                                                                     $excluded = array();
                                                                     $rule = excludeText($rule, $excluded);
                                                                     // check for .KEEP
                                                                     if (endsWith($rule, ROUTING_IDENTIFY_KEEP)) {
                                                                         /* do nothing */
                                                                     } else {
                                                                         if (endsWith($rule, ROUTING_IDENTIFY_INSPECT)) {
                                                                             $this->addInspect($node, $instruction);
                                                                         } else {
                                                                             if (strtoupper($rule) == ROUTING_IDENTIFY_EXIT) {
                                                                                 $this->addExit($node, $instruction);
                                                                             } else {
                                                                                 if (endsWith($rule, ROUTING_IDENTIFY_FILL)) {
                                                                                     $this->addSetFill($node, $instruction);
                                                                                 } else {
                                                                                     $this->addQuestion($node, $instruction);
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 function showOutputRouting()
 {
     $survey = new Survey($_SESSION['SUID']);
     $returnStr = $this->showOutputHeader($headers, false);
     require_once 'papergenerator.php';
     $gen = new PaperGenerator($_SESSION['SUID'], getSurveyVersion());
     $gen->generate(1);
     $returnStr .= $gen->getString();
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }