Ejemplo n.º 1
0
 function showCheckRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     $displaySysAdmin = new DisplaySysAdmin();
     $comp = loadvar("survey");
     $components = loadvar("components");
     if ($components == "") {
         return $displaySysAdmin->showCheck($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectComponent()));
     }
     set_time_limit(0);
     $messages = array();
     $survey = new Survey($comp);
     $checker = new Checker($comp);
     $compiler = new Compiler($comp, getSurveyVersion($survey));
     $sectionmessages = array();
     $routingmessages = array();
     $variablemessages = array();
     $typemessages = array();
     $groupmessages = array();
     $surveymessages = array();
     if (inArray(SURVEY_COMPONENT_ROUTING, $components)) {
         $sections = $survey->getSections();
         foreach ($sections as $section) {
             $mess = $compiler->generateEngine($section->getSeid(), false);
             if (sizeof($mess) > 0) {
                 $routingmessages[$section->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_SECTION, $components)) {
         $sections = $survey->getSections();
         foreach ($sections as $section) {
             $mess = $checker->checkSection($section, true);
             if (sizeof($mess) > 0) {
                 $sectionmessages[$section->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_VARIABLE, $components)) {
         $vars = $survey->getVariableDescriptives();
         foreach ($vars as $var) {
             $mess = $checker->checkVariable($var, true);
             if (sizeof($mess) > 0) {
                 $variablemessages[$var->getName()] = $mess;
                 $errors = true;
             }
             $mess = $compiler->generateSetFills(array($var), false, false);
             if (sizeof($mess) > 0) {
                 //print_r($mess);
                 if (isset($variablemessages[$var->getName()])) {
                     $variablemessages[$var->getName()] = array_merge($variablemessages[$var->getName()], $mess);
                 } else {
                     $variablemessages[$var->getName()] = $mess;
                 }
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_TYPE, $components)) {
         $types = $survey->getTypes();
         foreach ($types as $type) {
             $mess = $checker->checkType($type, true);
             if (sizeof($mess) > 0) {
                 $typemessages[$type->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_SETTING, $components)) {
         $mess = $checker->checkSurvey();
         if (sizeof($mess) > 0) {
             $surveymessages = $mess;
             $errors = true;
         }
     }
     if (inArray(SURVEY_COMPONENT_GROUP, $components)) {
         $groups = $survey->getGroups();
         foreach ($groups as $group) {
             $mess = $checker->checkGroup($group, true);
             if (sizeof($mess) > 0) {
                 $groupmessages[$group->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     $messages = array(Language::labelSections() => $sectionmessages, Language::labelVariables() => $variablemessages, Language::labelTypes() => $typemessages, Language::labelGroups() => $groupmessages, Language::labelSettings() => $surveymessages, Language::LabelRouting() => $routingmessages);
     if ($errors) {
         $m = '<a data-keyboard="false" data-toggle="modal" data-target="#errorsModal">Show error(s)</a>';
         $content .= $displaySysAdmin->displayError(Language::messageToolsCheckNotOk() . " " . $m);
     } else {
         $content .= $displaySysAdmin->displaySuccess(Language::messageToolsCheckOk());
     }
     $text = "";
     //print_r($messages);
     foreach ($messages as $k => $v) {
         if (sizeof($v) == 0) {
             //$text .= $displaySysAdmin->displaySuccess(Language::messageToolsCheckOk());
         } else {
             $text .= "<h3>" . $k . "</h3>";
             foreach ($v as $name => $m) {
                 foreach ($m as $object => $errors) {
                     if (is_array($errors)) {
                         foreach ($errors as $n) {
                             if (trim($n) != "") {
                                 $text .= $displaySysAdmin->displayError($name . ": " . $n);
                             }
                         }
                     } else {
                         if (trim($errors) != "") {
                             $text .= $displaySysAdmin->displayError($name . ": " . $errors);
                         }
                     }
                 }
             }
         }
     }
     $content .= $displaySysAdmin->displayRoutingErrorModal($survey, $text);
     return $displaySysAdmin->showCheck($content);
 }