function widgets_field_scan in Widgets 7
2 calls to widgets_field_scan()
- widgets_replace_fields in ./widgets.module
- widgets_template_auto_form in ./widgets.admin.inc
- Form structure for the template auto form.
File
- ./widgets.module, line 818
- Exposes global functionality for creating widget sets.
Code
function widgets_field_scan($text, $return_matches = FALSE) {
$pattern = '/
\\[\\? # [ - pattern start
([^\\s\\?=]*) # match $type not containing whitespace ? or =
= # = - separator
([^\\]]*) # match $name not containing or ? (TODO white space was removed, make sure it keeps working)
\\?\\] # ] - pattern end
/x';
$pattern = '/
\\[\\? # [ - pattern start
([^\\s\\?=]*) # match $type not containing whitespace ? or =
= # = - separator
(((?!\\?\\]).)*) # dont match ?]
\\?\\] # ] - pattern end
/x';
preg_match_all($pattern, $text, $matches);
if ($return_matches) {
return $matches;
}
if (strpos($text, 'profile_url=http://www.linkedin.com') !== FALSE) {
}
$originals = $matches[0];
$fields = $matches[1];
$defaults = $matches[2];
$pattern = '/
([^\\?]*) # match $type not containing whitespace ? or
\\{ # { start of var
([^\\?]*) # match $name not containing whitespace or ?
\\}
([^\\?]*)
/x';
$results = array();
for ($i = 0; $i < count($fields); $i++) {
if (preg_match_all($pattern, $defaults[$i], $matches)) {
$results[$fields[$i]] = array(
'pre' => $matches[1][0],
'default' => $matches[2][0],
'post' => $matches[3][0],
'original' => $originals[$i],
);
}
else {
$results[$fields[$i]] = array(
'default' => $defaults[$i],
'original' => $originals[$i],
);
}
}
return $results;
}