/** * Parse target content to replace TAGS like ##FULLFORM## by the values * * @param String $content String to be parsed * @param PluginFormcreatorFormanswer $formanswer Formanswer object where answers are stored * @return String Parsed string with tags replaced by form values */ private function parseTags($content, PluginFormcreatorFormanswer $formanswer) { $content = str_replace('##FULLFORM##', $formanswer->getFullForm(), $content); $section = new PluginFormcreatorSection(); $found = $section->find('plugin_formcreator_forms_id = ' . (int) $formanswer->fields['plugin_formcreator_forms_id'], '`order` ASC'); $tab_section = array(); foreach ($found as $section_item) { $tab_section[] = $section_item['id']; } if (!empty($tab_section)) { $question = new PluginFormcreatorQuestion(); $found = $question->find('plugin_formcreator_sections_id IN (' . implode(', ', $tab_section) . ')', '`order` ASC'); foreach ($found as $question_line) { $id = $question_line['id']; $name = $question_line['name']; $answer = new PluginFormcreatorAnswer(); $found = $answer->find('`plugin_formcreator_formanwers_id` = ' . (int) $formanswer->getID() . ' AND `plugin_formcreator_question_id` = ' . (int) $id); if (count($found)) { $datas = array_shift($found); $value = $datas['answer']; } else { $value = ''; } $value = PluginFormcreatorFields::getValue($question_line, $value); if (is_array($value)) { if ($GLOBALS['CFG_GLPI']['use_rich_text']) { $value = '<br />' . implode('<br />', $value); } else { $value = "\r\n" . implode("\r\n", $value); } } $content = str_replace('##question_' . $id . '##', $name, $content); $content = str_replace('##answer_' . $id . '##', $value, $content); } } return $content; }