42 $found = preg_match_all(
'/%(response_(\d+_)?q\d+[^%]*)%/U', $content, $set_matches, PREG_SET_ORDER);
43 $matches = array_merge($matches, $set_matches);
44 $found = preg_match_all(
'/%(question_name_(\d+_)?q\d+[^%]*)%/U', $content, $set_matches, PREG_SET_ORDER);
45 $matches = array_merge($matches, $set_matches);
46 $found = preg_match_all(
'/%(form_submission_[^%]*)%/U', $content, $set_matches, PREG_SET_ORDER);
47 $matches = array_merge($matches, $set_matches);
49 foreach ($matches as $match) {
50 if (empty($match))
continue;
54 $full_keyword = $match[1];
55 $keyword = parse_keyword($full_keyword, $modifiers);
57 $replacement = $form->_getThankYouKeywordReplacement($keyword);
58 if ($replacement ==
'%'.$keyword.
'%') {
62 if (!empty($modifiers)) {
63 $replace_keywords = Array(
64 'assetid' => $form->id,
65 'call_fns' => Array (
'_getThankYouKeywordReplacement',
'getKeywordReplacement'),
67 apply_keyword_modifiers($replacement, $modifiers, $replace_keywords);
69 $content = preg_replace(
'/%'.str_replace(
'^',
'\^', $match[1]).
'%/U', str_replace(
'$',
'\$', $replacement), $content, 1, $count);
75 replace_global_keywords($content);
90 preg_match_all(
'|%file_upload_([0-9]*_)?q([0-9]+)[^%]*%|U', $content, $matches);
92 foreach($matches[1] as $key => $section_match) {
93 $question_match = $matches[2][$key];
94 if (empty($section_match)) {
96 $section_assetid = $form->id;
97 $question_assetid = $question_match;
99 $section_assetid = str_replace(
'_',
'', $section_match);
100 $question_assetid = $question_match;
102 $question_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($section_assetid.
':q'.$question_assetid);
103 if(empty($question_asset) || get_class($question_asset) !=
'Form_Question_Type_File_Upload')
return $content;
107 if(isset($question_asset->extra_data[
'filesystem_path'])) {
108 $replacement = file_get_contents($question_asset->extra_data[
'filesystem_path']);
111 $uploaded_assetid = array_get_index($question_asset->extra_data,
'existing_file_assetid', array_get_index($question_asset->extra_data,
'new_file_assetid', NULL));
112 if (!empty($uploaded_assetid)) {
113 $file = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($uploaded_assetid);
114 $info = $file->getExistingFile();
115 if(isset($info[
'path']))
116 $replacement = file_get_contents($info[
'path']);
121 $full_keyword = trim($matches[0][$key],
'%');
122 $keyword = parse_keyword($full_keyword, $modifiers);
123 if (!empty($modifiers)) {
124 apply_keyword_modifiers($replacement, $modifiers);
126 $keyword = $full_keyword;
129 if (empty($section_match)) {
130 $content = str_replace(
'%'.$keyword.
'%', $replacement, $content);
132 $content = str_replace(
'%'.$keyword.
'%', $replacement, $content);
151 'must_contain' =>
'Must contain',
152 'must_contain_casesensitive' =>
'Must contain (Case sensitive)',
153 'must_not_contain' =>
'Must NOT contain',
154 'must_not_contain_casesensitive' =>
'Must NOT contain (Case sensitive)',
155 'equals' =>
'Must be equal to',
156 'equals_not' =>
'Must NOT be equal to',
157 'less_than' =>
'Must be less than',
158 'less_than_or_equal' =>
'Must be less than or equal to',
159 'more_than' =>
'Must be more than',
160 'more_than_or_equal' =>
'Must be more than or equal to',
178 $rule_type = array_get_index($rule,
'type',
'');
179 $rule_value = array_get_index($rule,
'value',
'');
181 switch ($rule_type) {
184 $valid = stripos($value, $rule_value) !== FALSE;
187 case 'must_not_contain':
188 $valid = stripos($value, $rule_value) === FALSE;
191 case 'must_contain_casesensitive':
192 $valid = strpos($value, $rule_value) !== FALSE;
195 case 'must_not_contain_casesensitive':
196 $valid = strpos($value, $rule_value) === FALSE;
200 $valid = $value == $rule_value;
204 $valid = !($value == $rule_value);
208 $valid = $value < $rule_value;
212 $valid = $value > $rule_value;
215 case 'less_than_or_equal':
216 $valid = $value <= $rule_value;
219 case 'more_than_or_equal':
220 $valid = $value >= $rule_value;
238 if (is_object($data)) $data = get_object_vars($data);
241 if (empty($data) && (is_array($data) || is_object($data)))
return '';
243 if(is_array($data)) {
245 foreach ($data as $index => $element) {
246 $result[$index] = self::toArray($element, $form);
251 return (self::getFileContentReplacementsFromForm($data, $form));