function asset_get_macros in Asset 6
Same name and namespace in other branches
- 5.2 asset.module \asset_get_macros()
- 5 asset.module \asset_get_macros()
Return all macros as an array.
6 calls to asset_get_macros()
- asset_filter in inc/
asset.node.inc - Implementation of hook_filter().
- asset_nodeapi in inc/
asset.node.inc - Implementation of hook_nodeapi() This is where we build the asset_node records.
- asset_wizard_form in ./
asset_wizard.inc - Main form builder function for the asset wizard.
- asset_wizard_form in inc/
asset_wizard.inc - Main form builder function for the asset wizard.
- asset_wizard_menu in ./
asset_wizard.module - Implementation of hook_menu().
File
- ./
asset.module, line 211
Code
function asset_get_macros($text) {
$m = array();
preg_match_all('/ \\[ ( [^\\[\\]]+ )* \\] /x', $text, $matches);
$tag_match = (array) array_unique($matches[1]);
// Don't process duplicates.
foreach ($tag_match as $macro) {
$current_macro = '[' . $macro . ']';
$param = array_map('trim', explode('|', $macro));
$func_name = array_shift($param);
// The first macro param is assumed to be the function name.
//$num_params = count($param); // Get the number of parameters
if ($func_name == 'asset') {
$vars = array();
foreach ($param as $p) {
$pos = strpos($p, '=');
$varname = substr($p, 0, $pos);
$varvalue = substr($p, $pos + 1);
$vars[$varname] = $varvalue;
}
// the full unaltered filter string is the key for the array of filter attributes
$m[$current_macro] = $vars;
}
}
return $m;
}