function checkGroup($group, $all = false) { // general if ($_SESSION['VRFILTERMODE_GROUP'] == 0 || $all == true) { if ($group->getTemplate() == TABLE_TEMPLATE_CUSTOM) { $text[] = $group->getCustomTemplate(); } } // verification if ($_SESSION['VRFILTERMODE_GROUP'] == 1 || $all == true) { $text[] = $group->getMinimumRequired(); $text[] = $group->getMaximumRequired(); $text[] = $group->getExactRequired(); } // display if ($_SESSION['VRFILTERMODE_GROUP'] == 2 || $all == true) { $text[] = $group->getPageHeader(); $text[] = $group->getPageFooter(); $text[] = $group->getLabelBackButton(); $text[] = $group->getLabelNextButton(); $text[] = $group->getLabelDKButton(); $text[] = $group->getLabelRFButton(); $text[] = $group->getLabelNAButton(); $text[] = $group->getLabelUpdateButton(); $text[] = $group->getLabelRemarkButton(); $text[] = $group->getLabelRemarkSaveButton(); $text[] = $group->getLabelCloseButton(); if (inArray($group->getTemplate(), array_keys(Common::surveyTableTemplates()))) { $text[] = $group->getTableID(); $text[] = $group->getTableWidth(); $text[] = $group->getQuestionColumnWidth(); } } // assistance if ($_SESSION['VRFILTERMODE_GROUP'] == 3 || $all == true) { $text[] = $group->getErrorMessageExclusive(); $text[] = $group->getErrorMessageInclusive(); $text[] = $group->getErrorMessageMinimumRequired(); $text[] = $group->getErrorMessageExactRequired(); $text[] = $group->getErrorMessageMaximumRequired(); $text[] = $group->getErrorMessageUniqueRequired(); } // navigation if ($_SESSION['VRFILTERMODE_GROUP'] == 4 || $all == true) { $text[] = $group->getKeyboardBindingBack(); $text[] = $group->getKeyboardBindingNext(); $text[] = $group->getKeyboardBindingUpdate(); $text[] = $group->getKeyboardBindingClose(); $text[] = $group->getKeyboardBindingDK(); $text[] = $group->getKeyboardBindingRF(); $text[] = $group->getKeyboardBindingNA(); $text[] = $group->getKeyboardBindingRemark(); } // check for references $fills = getReferences(implode(" ", $text), INDICATOR_FILL); $fills1 = getReferences(implode(" ", $text), INDICATOR_FILL_NOVALUE); $fills2 = getReferences(implode(" ", $text), INDICATOR_INLINEFIELD_ANSWER); $fills3 = getReferences(implode(" ", $text), INDICATOR_INLINEFIELD_TEXT); $fills = array_unique(array_merge($fills, $fills1, $fills2, $fills3)); $messages = $this->checkReferences($fills); // interactive if ($_SESSION['VRFILTERMODE_GROUP'] == 6 || $all == true) { $functions[] = $group->getOnBack(); $functions[] = $group->getOnNext(); $functions[] = $group->getOnDK(); $functions[] = $group->getOnRF(); $functions[] = $group->getOnNA(); $functions[] = $group->getOnUpdate(); $functions[] = $group->getOnLanguageChange(); $functions[] = $group->getOnModeChange(); $functions[] = $group->getOnVersionChange(); foreach ($functions as $f) { if (!inArray(trim($f), array("", SETTING_FOLLOW_GENERIC, SETTING_FOLLOW_TYPE))) { if (function_exists($f) == false) { $messages[] = Language::messageCheckerFunctionNotExists($f); } } } } return $messages; }
function replaceFills($text, $updateinlinefields = false) { $cnt = 0; if (trim($text) == "") { return $text; } while (strpos($text, INDICATOR_FILL_NOVALUE) !== false) { $fills = getReferences($text, INDICATOR_FILL_NOVALUE); // sort fills by longest keys //uksort($fills, "compareLength"); usort($fills, "reversenat"); foreach ($fills as $fill) { $fillref = $fill; //str_replace("[", "\[", str_replace("]", "\]", $fill)); $filltext = strtr($this->getFillValue(INDICATOR_FILL_NOVALUE . $fill), array('\\' => '\\\\', '$' => '\\$')); $pattern = "/\\" . INDICATOR_FILL_NOVALUE . preparePattern($fillref) . "/i"; $text = preg_replace($pattern, $filltext, $text); //echo 'NOW: ' . $text . "<br/>"; } $cnt++; /* stop after 999 times */ if ($cnt > 999) { break; } } $cnt = 0; while (strpos($text, INDICATOR_FILL) !== false) { $fills = getReferences($text, INDICATOR_FILL); // sort fills by longest keys //uksort($fills, "compareLength"); usort($fills, "reversenat"); foreach ($fills as $fill) { $fillref = $fill; // str_replace("[", "\[", str_replace("]", "\]", $fill)); $filltext = strtr($this->getDisplayValue($fill, $this->getFillValue($fill)), array('\\' => '\\\\', '$' => '\\$')); $pattern = "/\\" . INDICATOR_FILL . preparePattern($fillref) . "/i"; $text = preg_replace($pattern, $filltext, $text); //echo 'NOW: ' . $text . "<br/>"; } $cnt++; /* stop after 999 times */ if ($cnt > 999) { break; } } if ($updateinlinefields) { $text = $this->updateInlineFields($text); } return $text; }
function renderTemplateHeading($tData, $references) { ?> <table> <colgroup width="20%"></colgroup> <colgroup width="5%"></colgroup> <colgroup width="10%"></colgroup> <colgroup width="65%"></colgroup> <tbody> <tr> <th>Max Number of Cycles:</th> <td><?php echo $tData['CourseNumMax']; ?> </td> <th>Cycle Length:</th> <td><?php echo $tData['length'] . " " . $tData['CycleLengthUnit']; ?> </td> </tr> <tr> <th>Chemotherapy Regimen Name:</th> <td colspan="3"><?php echo $tData['name']; ?> </td> </tr> <tr> <th>Description:</th> <td colspan="3"><?php echo $tData['description']; ?> </td> </tr> <tr><th colspan="4"> </th></tr> <tr> <th>Emetogenic level:</th> <td colspan="3"><?php echo $tData['emoLevel']; ?> </td> </tr> <tr> <th>Febrile Neutropenia risk:</th> <td colspan="3"><?php echo $tData['fnRisk']; ?> %</td> </tr> <tr> <th>Reference:</th> <td colspan="3"> <?php getReferences($references); ?> </td> </tr> </tbody> </table> <?php }
function replaceFills($text) { $fills = getReferences($text, INDICATOR_FILL); if (sizeof($fills) > 0) { uksort($fills, "compareLength"); foreach ($fills as $fill) { $fillref = str_replace("[", "\\[", str_replace("]", "\\]", $fill)); $filltext = strtr($this->getFieldFromFill($fill), array('\\' => '\\\\', '$' => '\\$')); $pattern = "/\\" . INDICATOR_FILL . $fillref . "/i"; $text = preg_replace($pattern, $filltext, $text); } } $fills = getReferences($text, INDICATOR_FILL_NOVALUE); if (sizeof($fills) > 0) { uksort($fills, "compareLength"); foreach ($fills as $fill) { $fillref = str_replace("[", "\\[", str_replace("]", "\\]", $fill)); $filltext = ""; //strtr($this->getFieldFromFill($fill), array('\\' => '\\\\', '$' => '\$')); $pattern = "/\\" . INDICATOR_FILL_NOVALUE . $fillref . "/i"; $text = preg_replace($pattern, $filltext, $text); } } $fills = getReferences($text, INDICATOR_INLINEFIELD_TEXT); if (sizeof($fills) > 0) { uksort($fills, "compareLength"); foreach ($fills as $fill) { $fillref = str_replace("[", "\\[", str_replace("]", "\\]", $fill)); $filltext = ""; //strtr($this->getFieldFromFill($fill), array('\\' => '\\\\', '$' => '\$')); $pattern = "/\\" . INDICATOR_INLINEFIELD_TEXT . $fillref . "/i"; $text = preg_replace($pattern, $filltext, $text); } } $fills = getReferences($text, INDICATOR_INLINEFIELD_ANSWER); if (sizeof($fills) > 0) { uksort($fills, "compareLength"); foreach ($fills as $fill) { $fillref = str_replace("[", "\\[", str_replace("]", "\\]", $fill)); $filltext = ""; //strtr($this->getFieldFromFill($fill), array('\\' => '\\\\', '$' => '\$')); $pattern = "/\\" . INDICATOR_INLINEFIELD_ANSWER . $fillref . "/i"; $text = preg_replace($pattern, $filltext, $text); } } return $text; }
function updateInlineFields($text = array()) { if (sizeof($text) == 0) { return; } /* keep track */ $classes = $this->loadInlineFieldClasses(); //print_r($getfillclasses); //echo 'ggggg'; $fills = getReferences(implode(" ", $text), INDICATOR_INLINEFIELD_ANSWER); $fills2 = getReferences(implode(" ", $text), INDICATOR_INLINEFIELD_TEXT); $fills3 = array_unique(array_merge($fills, $fills2)); /* go through fills */ foreach ($fills3 as $fill) { /* not processed before */ //if (!isset($classes[strtoupper($fill)])) { if ($fill != "") { $classes['"' . strtoupper($fill) . '"'] = $this->addInlineField($fill); } //echo $fill . $classes[strtoupper($fill)] . "<hr><hr>"; //} } /* check for first time */ $this->addContext(); /* store in db */ global $db; $bp = new BindParam(); $bp->add(MYSQL_BINDING_STRING, gzcompress(serialize($classes), 9)); $bp->add(MYSQL_BINDING_INTEGER, $this->suid); $bp->add(MYSQL_BINDING_INTEGER, $this->version); $query = "update " . Config::dbSurvey() . "_context set inlinefields = ? where suid=? and version = ? "; $db->executeBoundQuery($query, $bp->get()); }
function updateVariableValue($old, $new, $val) { // check fills $fills = getReferences($val, INDICATOR_FILL); $fills2 = getReferences($val, INDICATOR_FILL_NOVALUE); $fills3 = getReferences($val, INDICATOR_INLINEFIELD_ANSWER); $fills4 = getReferences($val, INDICATOR_INLINEFIELD_TEXT); usort($fills, "reversenat"); foreach ($fills as $fill) { $newfill = preg_replace("/\\b" . $old . "\\b/i", $new, $fill); if ($newfill != $fill) { $pattern = "/\\" . INDICATOR_FILL . preparePattern($fill) . "/i"; $val = preg_replace($pattern, INDICATOR_FILL . $newfill, $val); } } // check fills no values usort($fills2, "reversenat"); foreach ($fills2 as $fill) { $newfill = preg_replace("/\\b" . $old . "\\b/i", $new, $fill); if ($newfill != $fill) { $pattern = "/\\" . INDICATOR_FILL_NOVALUE . preparePattern($fill) . "/i"; $val = preg_replace($pattern, INDICATOR_FILL_NOVALUE . $newfill, $val); } } // check inline fields usort($fills3, "reversenat"); foreach ($fills3 as $fill) { $newfill = preg_replace("/\\b" . $old . "\\b/i", $new, $fill); if ($newfill != $fill) { $pattern = "/\\" . INDICATOR_INLINEFIELD_ANSWER . preparePattern($fill) . "/i"; $val = preg_replace($pattern, INDICATOR_INLINEFIELD_ANSWER . $newfill, $val); } } // check inline field texts usort($fills4, "reversenat"); foreach ($fills4 as $fill) { $newfill = preg_replace("/\\b" . $old . "\\b/i", $new, $fill); if ($newfill != $fill) { $pattern = "/\\" . INDICATOR_INLINEFIELD_TEXT . preparePattern($fill) . "/i"; $val = preg_replace($pattern, INDICATOR_INLINEFIELD_TEXT . $newfill, $val); } } // return result return $val; }
function handleFills($text) { $cnt = 0; while (strpos($text, INDICATOR_FILL) !== false) { $fills = getReferences($text, INDICATOR_FILL); // sort fills by longest keys usort($fills, "reversenat"); foreach ($fills as $fill) { $fillref = $fill; // str_replace("[", "\[", str_replace("]", "\]", $fill)); $filltext = strtr(FILL_MARKER . $this->handleFill($fill) . FILL_MARKER, array('\\' => '\\\\', '$' => '\\$')); $pattern = "/\\" . INDICATOR_FILL . preparePattern($fillref) . "/i"; $text = preg_replace($pattern, $filltext, $text); //echo 'NOW: ' . $text . "<br/>"; } $cnt++; /* stop after 999 times */ if ($cnt > 999) { break; } } $text = str_replace("'", "\\'", $text); return str_replace(FILL_MARKER, "^", $text); }