| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 #fmtsub - perform substitutions 2 3 # Constants 4 5 sub fmt { 6 7 local(@data); 8 local($tmpl) = shift; 9 if ($tmpl) { local(@tmpl) = @$tmpl } 10 local($data) = shift; 11 if ( $data ) { @data = @$data } 12 local($rslt)=""; 13 local(@rlst)=(); 14 15 16 local($look_keywd)=1; 17 local($n_key)=0; 18 local($keywd,$line,$value); 19 undef(%key); 20 21 foreach (@data) 22 { 23 # 24 # look for lines of the form :key: 25 # 26 if ($look_keywd) 27 { if(/:(\w+):/) 28 { $keywd=$1; 29 $look_keywd=0; 30 s/:\w+://; 31 s/^[ \t]*//; 32 s/[ \t]*$//; 33 s/^\n$//; 34 $line=$_; 35 next; 36 } 37 } 38 else 39 { if(/:(\w+):/) 40 { $look_keywd=1; 41 chop($line); 42 $key{$keywd} = $line; 43 redo; 44 } 45 $line=$line . $_; 46 } 47 } 48 # last keyword 49 chop($line); 50 $key{$keywd} = $line; 51 52 foreach (@tmpl) 53 { 54 if (/#/) { 55 while(1) 56 { 57 last if(! /#([^#]+)#/); 58 if (defined ($value=$key{$1})) { 59 s/#$1#/$value/e; 60 next; 61 } elsif ( s/^([^#]*)#\w+#/\1/ ) { 62 next; 63 } else { 64 last if (! /(.*#.*)(#.*#.*)/); 65 $rslt .= $1; 66 $_ =$2 . "\n"; 67 } 68 } 69 } 70 $rslt .= $_; 71 push(@rslt,$_); 72 } 73 return wantarray ? @rslt : $rslt; 74 } 75 1;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |